void String::copyFromUTF16(...) - Comments

Festus Hagen festushagenlists at yahoo.com
Tue Jan 21 11:46:49 UTC 2014


Hi all,

Asking cause I don't know!

In the two:
    void String::copyFromUTF16(const wchar_t *s, size_t length, Type t)
    void String::copyFromUTF16(const char *s, size_t length, Type t)

This just don't look right to me ... The comments don't fit the code? Or am I missing something?
        if(length >= 1 && s[0] == 0xfeff) 
          swap = false; // Same as CPU endian. No need to swap bytes.
Same as CPU endian?, How does it know that?
Isn't it Big Endian regardless of CPU?
Thus the comment should be something like: It's Big endian so don't swap bytes.

Simular here.
        else if(length >= 1 && s[0] == 0xfffe) 
          swap = true;  // Not same as CPU endian. Need to swap bytes.
Not same as CPU endian?, How does it know that?
Isn't it Little Endian regardless of CPU?
Thus the comment should be something like: It's Little Endian so swap bytes

If I understand this correctly, input (s) with Type=UTF16 can be either BE or LE, output will always be BE?

Thanks
-Enjoy
fh : )_~



More information about the taglib-devel mailing list