[ID3 Dev] Unicode
Ben Allison
benski at winamp.com
Mon Feb 12 12:43:14 PST 2007
Rob,
Had forgotten about the sizeof(wchar_t) != 2 on all platforms (see
earlier post). But the rest of the code is OK. It's not detecting
big-endian versus little-endian, just whether or not you need to swap
endianness.
The intent of my post was to be sure that people aren't confused by the
fact that literal numbers in C are defined in big endian notation. I
think I probably just made the situation worse, though :)
-ben
Robert Manson wrote:
> Hi Ben,
> With regards to your comment:
>
>>> it will also do the right thing, regardless of platform.
>>>
> If you're intent here was to indicate that the code snippets you posted
> are portable I'm afraid you are mistaken.
>
> The wchar_t type is not portable instead you should use ui16_t for
> UTF-16 (or UCS-2). (whar_t is 16 bits on windows but 32 bits on linux,
> and is not guaranteed to be more than 7 bits) Also note that ui16_t is
> guaranteed to be *at least* 2 bytes so you should not use sizeof(),
> instead you should use the number 2.
>
> Also, while it is true that literal values are big endian, the byte
> ordering of the lval is system dependent so the code snippets will
> produce different results depending on whether or not the platform is
> big or little endian.
>
> -Rob
---------------------------------------------------------------------
To unsubscribe, e-mail: id3v2-unsubscribe at id3.org
For additional commands, e-mail: id3v2-help at id3.org
More information about the ID3v2
mailing list