Re: std::cout << Glib::ustring(utf8_literal) throws exception



On Sun, 13 Jul 2008 15:17:31 -0700
Sohail Somani <sohail taggedtype net> wrote:
> Great, I thought this was exactly the problem as well! Now, do you
> know how I can set Windows XP to have a locale of "UTF-8"? I can't
> figure it out nor can I convince Professor Google to let me cheat on
> the test :-(

Ah, so you are using windows.  Well, I doubt that you can, since windows
uses UTF-16.

If you are outputting to a console, then the console should handle both
UTF-16 and a narrow character set.  If you want to stick to a narrow
codeset, the best thing would be to set the narrow codeset of the
console to the one used by your program, and you can set the one in
your program by stating it specifically in the call to setlocale(). I
do not know how you set the narrow character codeset of a windows
console.

However, why not convert your string to UTF-16 and output it that way
(using wcout)?  I know very little about windows consoles (except of
course that UTF-16 is the worst of all possible choices), but I assume
wcout will handle a non-fixed size wide character set - the windows
console would be pretty useless if it didn't.

Alternatively, try switching to a decent OS which uses UTF-8 (narrow
codeset) and UCS-4 (fixed width wide codeset) - that is most modern
unix-like OSes.

Chris



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]