Convert to Unicode

Hello,

Part 3 in my series of game dev improvement questionaire Smiling i know hobbe pretty recently converted twtpb to unicode. i was thinking of doing the same before going too far with ansi again. i found this cheat sheet http://www.i18nguy.com/unicode/c-unicode.html which explains most of the things you need to do. however, i'd like to stay off microsoft-only solutions.

so my question is what did you have to change and did you use crossplatform solutions and if not, how would you go about handling stdstrings and utf-8 for string handling and file management? assuming you use stl of course... thats what i do.

users avatar

I went for a quick and dirty

I went for a quick and dirty solution, and only translated strings that actually where actually needed. That is the strings visible in the UI. I used std::wstring for this. Since my game have full control over the files read/written there was no need for me to do some full conversion.

I smell... some over engineering here Eye-wink

users avatar

What we did on Ground Control 2...

Similar to what hObbE is suggesting, on Ground Control 2 (www.massive.se) we only used UTF-8 for the strings that were visible, i.e. we used multibyte for the rest of the codebase.

We probably even had a custom string class that used unsigned short instead of char too... Laughing out loud

/johno
"you can't stop the change"

users avatar

heh i didnt know how deep to

heh i didnt know how deep to go so its good i asked then. so to sum up i can continue with the codebase i have but for UI strings i can load the strings from a utf-8 file and load them into wstrings and use them when i display the text with a font class that can use wstrings. that way i dont have to convert the rest of the project.

---------------
Solid Core Entertainment
Developer of Roadclub

users avatar

this looks promising. i'm

this looks promising. i'm noting it here for future reference. http://utfcpp.sourceforge.net/

---------------
Solid Core Entertainment
Developer of Roadclub

users avatar

In T.W.T.P.B. I also made

In T.W.T.P.B. I also made another simplification; all strings are just present in a language specific header file, that is not read from a file. Building for different languages then only became the simple matter of including the right header.

users avatar

that would mean different

that would mean different exes for different languages and no ingame language setting. i guess thats ok though.

---------------
Solid Core Entertainment
Developer of Roadclub

users avatar

exactly, and that was the

exactly, and that was the case of T.W.T.P.B. with a separate polish version.

Also I guess it would be no problem making a simple interface and have dynamic languages. The obvius advantage above havng stuff in a file is that you can get the compiler to tell you if you missed something.

Imho getting a compiler error for stuff is a huge advantage.

users avatar

i totally agree. i'd rather

i totally agree. i'd rather have a list of errors instead of hidden bugs. i've spent way too much time debugging things in the past. i'm using exceptions in the next game instead of if(X == NULL) checks everywhere Smiling

I always thought exceptions was a pain cluttering up the code but if you use it in the right places and place a catcher on top instead of everywhere you get more solid debug information without too much hassle.

---------------
Solid Core Entertainment
Developer of Roadclub

users avatar

cool! The only problem I

cool! The only problem I have with exceptions are that they are not mandatory so I tend to forget them Puzzled Automatic Unit testing is another path to try out that can prove very beneficial in finding errors.

users avatar

it does work better in

it does work better in certain industrial applications and the like than in games though. you need to have clear and simple tasks with an expected value as a result.

---------------
Solid Core Entertainment
Developer of Roadclub

users avatar

Post new comment

Please solve the math problem above and type in the result. e.g. for 1+1, type 2.
The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <h1> <h2> <h3> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.
  • Images can be added to this post.

More information about formatting options