Christian Biesinger wrote:
steve lu wrote:

    for(; start < end; ++start)
    {
        *wstart = (wchar_t) *start;


This assumes that the wchar_t uses UTF-16 as its encoding. Therefore, this will produce wrong results on non-windows platforms...

    size_t size = wcstombs((char*)ptr.data(), wpr, 4096);


Err, this can return -1. You should handle that case, it's a quite real possibility on windows, where the system charset tends to be only a small subset of unicode.

(This also fails for strings larger than 4096 characters, and you could avoid that by calling wcstombs with NULL as the first argument to get the required size)

I have done this task in the same way. The mozilla strings guide advises use only nsAString. The nsAString hasn’t got method for conversion. What should I do? I have to use my own unsafe code.
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to