ShiVa3D
Script Editor: Save files as UTF-8
You need some features? ask it to us here!Script Editor: Save files as UTF-8
by giggsy » 24 Apr 2012, 08:56
Maybe something for 2.0 
We are currently implementing localization, and you can run into trouble if you use UTF-8 text and hardcoded values from within LUA becuause the LUA files are saved in ASCII.
E.g.:
- hText is UTF-8 encoded.
- localization.get ( "SomeStringId" ) returns an UTF-8 encoded string, e.g. "You need more %s"
- "~" is our bitmap font symbol for a coin icon
Now this works for the "~", but e.g. not for "§", because that character doesn't appear to be compatible between ASCII & UTF-8 ... and that leads to very strange results.
It would be cool if you could save your lua files in UTF-8!
Questions that occur:
- What would happen if it's the other way around (lua file = UTF-8, hText = ASCII)?
- Do you actually have any big benefits from using ASCII? Shouldn't you just enforce UTF-8?
We are currently implementing localization, and you can run into trouble if you use UTF-8 text and hardcoded values from within LUA becuause the LUA files are saved in ASCII.
E.g.:
- Code: Select all
local hText = hud.getComponent ( hUser, sName..".Text" )
hud.setLabelText ( hText, string.format ( localization.get ( "SomeStringId" ), "~" ) )
- hText is UTF-8 encoded.
- localization.get ( "SomeStringId" ) returns an UTF-8 encoded string, e.g. "You need more %s"
- "~" is our bitmap font symbol for a coin icon
Now this works for the "~", but e.g. not for "§", because that character doesn't appear to be compatible between ASCII & UTF-8 ... and that leads to very strange results.
It would be cool if you could save your lua files in UTF-8!
Questions that occur:
- What would happen if it's the other way around (lua file = UTF-8, hText = ASCII)?
- Do you actually have any big benefits from using ASCII? Shouldn't you just enforce UTF-8?
-

giggsy - Platinum Boarder

- Posts: 1011
- Location: Austria
1 post
• Page 1 of 1