nb Core Community
February 09, 2012, 07:39:27 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: 1.2.3 +nb is now final and released

@new registrations. I will not allow any new registrations here as there are more (real person) spambots here than ever.... captcha proved to be ineffective.

After your registration, mail me at ( admin AT shinobilegends.com ) from the mail address you want to register. Provide some text about you and possibly your game.
 
   Home   Help Search Calendar Downloads Login Register  
Pages: [1]
  Print  
Author Topic: UTF-8 (multibyte chars) and the game  (Read 799 times)
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« on: July 27, 2008, 08:53:44 am »

In several locations, you might have problems when a user writes over the hard character limit (i.e. 50 in the title) with an multibyte character.

In this case, the char will "break in two" with only the first part saved... an invalid char.

As I just had with a clan motd, this can mean you can display it with the wrong char at the end (an ? normally as the browser can't interpret  that) but an textarea box i.e. will be empty... because the htmlentities function will return nothing there...

Solution: remove the last character and it will work again.

I don't know if I do a complete core solution to work with those char problems... it's hard to grab as html elements only take "char" as counter, and char=1 for them, they don't calculate *how much space* I need in the database.

However, we could simply scale the DB fields larger, to fetch and save such overheads. In the clans,however a substr() is done which breaks it Wink an mb_substr would suffice.
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Wasili
Guest
« Reply #1 on: July 28, 2008, 06:37:36 pm »

I overload, in my version of 0.9.7, all string functions with a mb-equivalent. And also, of course, I converted all files and the database to Unicode. It works perfectly and I never hat any problem with broken names.
I don’t need HTMlEntities anymoire, only HTMLSpecialchars which would replace <, > and ".
The only limitation is that you must edit the php.ini or overwrite the settings in a .htaccess-file.

Code:
php_value mbstring.func_overload

php_value mbstring.internal_encoding UTF-8
Logged
Nightborn
Administrator
Sr. Member
*****

Karma: +20/-0
Posts: 306



View Profile WWW
« Reply #2 on: July 29, 2008, 07:26:01 am »

I suspect the broken stuff comes from the database format and field length there.

Lotgd does not set any charset there, just uses the default one. Hence the errors I presume.

it has not really something to do with the php mb_ functions.

Also, I have currently in the titlechanger hardcoded a strlen (no mb_) in it to make at least a proper insert as I *don't know* what kind of charset to expect in the db.

I am aware this is not 100% properly solved Sad
Logged

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!