I learned something new over REAL World last week (see, even REAL Software employees have something to gain from attending!) with regards to the way the Encodings.GetFromCode API works in REALbasic. I was always under the impression that this API was a Mac-only one. However, it turns out that I was wrong -- it works on Windows as well (sorry, I'm not certain about Linux one way or the other).
GetFromCode takes a codepage on Windows, but it takes it in a strange enough fashion that we can figure out what you really mean. If you add &hFFFF0000 to the Win32 code page identifier, then that tells REALbasic "this is a Win32 code page, so use it as such" and it uses the low 16-bit word as the code page. So, for instance, the following are identical:
s = DefineEncoding( someString, Encodings.WindowsArabic )
s = DefineEncoding( someString, Encodings.GetFromCode( &hFFFF0000 + 1256 ) )
They both use the same code page (1256) to denote Arabic. This is a very powerful feature if you're stuck dealing with code pages instead of Unicode text because the Encodings object doesn't expose every Win32 code page. For instance, there's no entry for ISCII Kannada (57008), etc. So now you've got a solution if you're one of those unfortunate souls.
As always -- use Unicode whenever possible. It will make your life much, much easier in the long run.
You could almost hear this post belly flop into the pool off the high diving tower :)
Now we can use very complicated encodings in Japanese both on Mac and Win. I told this detection to Japanese Rb users by Japanese Mailing list.
I appreciate for your post. thank you!
Do you know of way to list all available encodings for WIndows (and Linux, if possible)? I fould a way to do it under OS X (Carbon) at http://www.nilobject.com/2007/05/21/example-code-from-real-world-list-of-available-encodings and you mention there that you may have a solution for Windows? Please post the solution somewhere, I'm sure it would be useful for many developers. Thank you, regards -- Johannes
@Johannes Rukkers -- You can use the EnumSystemCodePages Win32 API to enumerate over the installed code pages on the system. If you need something more concrete than that, then please send me an email and I'd be happy to email you a project back.