Re: Encoding of "long string"
Re: Encoding of "long string"
- Subject: Re: Encoding of "long string"
- From: Steve Checkoway <email@hidden>
- Date: Tue, 11 Dec 2007 21:43:58 -0800
David Dunham wrote:
I've inherited some C++ code that uses
L"foo"
to specify strings. I'm well aware that this has some problems, but it's
what I've got. In the process of trying to fix this and make it actually
cross-platform and Unicode savvy, I have a question: what encoding does
gcc use for the resulting string? I'm guessing this is not actually
UTF-16 like the authors think (assuming they know about encodings).
This is definitely not going to be UTF-16, but you can easily check for
yourself. Try:
g++ -Wall -S -x c++ -o foo.s - <<< 'const wchar_t *foo = L"foo";'
and then take a look at foo.s. On linux (my Mac laptop is closed as I'm
about to leave), I see,
.string "f"
.string ""
.string ""
.string "o"
.string ""
.string ""
.string "o"
.string ""
.string ""
.string ""
.string ""
.string ""
.string ""
So it's clearly 4 bytes per character and ends with the 4 byte L'\0'.
This is what I'd expect from a 4 byte wchar_t. I haven't had problems
using this in Mac OS X, (x86, x86_64, ppc) Linux, and Windows
cross-platform code. YMMV.
--
Steve Checkoway
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden