site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Sun, 27 Mar 2005 09:30:24 +1000 Warwick Hall <phosgate@unwired.com.au> wrote:
I have downloaded expat-1.95.8 (an XML cross platform C lib) and it has the option of using UTF-16, which is passed around in wchar_t* variables. I want to print these variables out to stdout, and i am not having any luck.
I think Expat's UTF-16 mode is largely for Windows and certain environments (are C++ strings always UTF-16?). For Darwin, or just about any other Unix based OS, you want to use the non-wide character mode. Just make sure you call setlocale(LC_CTYPE, ""). Then it's up to the environment of the user to ensure the locale encoding is UTF-8. I'd be willing to bet $1 Darwin is UTF-8 throughout by default. Note that there are some minor gotchas to look out for when working with UTF-8 though. For example you cannot necessarily iterate over each character by simply examining each element in the array. Each character may occupy between 1 and 6 bytes [1].
Could it be that expat is assuming wchar_t is 2 bytes instead of the 4 bytes of darwin running on powerpc?
I *think* Expat's wchar_t is hardcoded at 2 bytes (UTF-16LE) period. Mike [1] http://www.cl.cam.ac.uk/~mgk25/unicode.html -- IRC - where men are men, women are men, and the boys are FBI agents. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com