Re: Unicode and C++



Nathan Myers <ncm@nospam.cantrip.org> writes:

> > Also you can use ASCII string literals with UTF8, which means you can
> > usually use string literals (most apps use English for their gettext
> > keys). People simply won't accept not being able to use string
> > literals.
> 
> There is no problem with wide character string literals in C or C++, 
> and hasn't been for a very long time.  Simply prefix with a letter 'L'.
> 
>   wchar_t hello = L"hello, world";

Perhaps it wouldn't be if there was agreement on:

 - The encoding for source code files. (It certainly shouldn't
   be dependent on the user's locale.)

 - The width of wchar_t

 - The encoding of wchar_t

The C standard makes no guarantees about any of these, and
my copy of GCC (CVS snapshot from a few weeks ago, I think)
certainly doesn't do what I would consider the right thing. 

 L"utf8-text"

Gives you a string where each 4-byte wide character contains
one byte of the UTF-8 string. Maybe I'm missing something,
but relying on the L"" to do _anything_ predictable in 
a portable program seems like a very poor idea.

Regards,
                                        Owen




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