Win32 : Proper Unicode support

BlitzMax Forums/BlitzMax Module Tweaks/Win32 : Proper Unicode support

Brucey(Posted 2007) [#1]
It turns out that MaxGUI on Windows doesn't support Unicode/UTF-8 properly on a lot of the gadgets.

After having a rummage through the code, MSDN, and with some assistance from Google, I've come up with a possible fix.

I've tested it with my Localization app, and the native languages appear correctly now in ListBoxes and ComboBoxes - something they didn't before.

It'll probably need some more testing, if anyone is interested????, as it only took an hour and a half to hack the code into its present shape - and likely I've missed stuff.

Rather than post all the changes here, since I had to edit nearly ALL the files in the win32gui folder... I've uploaded the "tweaked" win32gui module HERE (380k).

Essentially, what I've done is set a pre-processor variable UNICODE, which changes all the string internals to use WCHAR instead of char in calls to the API.
Therefore, anywhere which uses a string, or calls cstr(), etc, needed changed to use bbStringToWString() and such like.

And by George... it seems work...

;o)


Disclaimer: As stated above, I might have missed something, so beware. If you do find some text not working as expected, please let me know.

Edit: The only thing I don't know about, is what versions of Windows are *not* Unicode friendly? Cuz I doubt this would work too well on those versions. Since I only have access to Win2k, it's not a problem for me.


skidracer(Posted 2007) [#2]
Hi Brucey, see here for a beta of new win32maxgui module which you may have missed that is pure bmx implementation of win32maxgui using unicode.

Win98 needs a unicows.dll to be loaded for unicode apps, it is not freely distributable, although I think you only need to implement a disclaimer of some sorts to keep Microsoft happy, hence the conservative just implement unicode in the textarea if not win98 approach in the current version of win32maxgui. The next optimization I was going to try for the win32 textarea was cache the contents in rtf, which even less amusing is ascii with stupid long sequences for unicode characters.


Brucey(Posted 2007) [#3]
Hi skid :-)

I've been watching that thread, but I was thinking it's maybe a bit too cutting edge for what I was playing with. That and my Win32 time is limited to squeezing in between "real" work ;-)

However, I'll have a go and see how I get on with it.

I'm happy, however, with the way this gui hack is, since it lets my windows build work in exactly the same way as the GTK and OS X builds.