jtuchel wrote:Marten, Taylor,
are there any code samples available as a quick start into supporting Unicode by converting?
If I assume, that all my text is stored as UTF-8 strings (as for example within the sqlite database), then I would use this code (Windows only !) to convert each string within my application before binding the converted value to an insert/update string column parameter within my sql statement (as an usage example):
Therefore the "storing"-part must execute stuff like:
- Code: Select all
^(AbtCodePageConverter current
convert: currentCodePageString
fromCodePage: AbtCodePageConverter currentCodePage
toCodePage: AbtCodePageConverter utf8CodePage) trimNull
and the "loading" part:
- Code: Select all
^(AbtCodePageConverter current
convert: utf8String
fromCodePage: AbtCodePageConverter utf8CodePage
toCodePage: AbtCodePageConverter currentCodePage) trimNull
.
Within a multi-user/multi-session application you must get/store the "AbtCodePageConverter currentCodePage" value from/to your session bindings and not from the global image settings.
Therefore having a multi-user/session/language application you would store all your texts as utf8 based strings in different languages in your "database". And then the user selects a native language and its code page (however you get it) and then the conversion should work.
The other question may be: if I have not a native client, but want to work with a different code page than the default code page, you may need additional code to sort and compare strings .... the built-in stuff (Locale) does only work against the current code page ... but then you may use third-party libraries to do this work ....
To make this work with databases you must consider the connection settings available on various database products - as an example: database kernel working on utf8, but each connection may have a different code page. Then the conversion is done already internally within the database driver ... then the conversion is not needed at all in the VA code. Or you make the decision, that you set the client connection code page always to UTF-8, then your Smalltalk code has to do the conversion again. And again: special thoughts have to be done when doing sorting or searching ....