(resend - arg)

On Tue, Apr 28, 2009 at 2:47 PM, Greg Spencer <gspen...@google.com> wrote:

> On Tue, Apr 28, 2009 at 2:41 PM, Amanda Walker <ama...@chromium.org>wrote:
>
>>
>> On Tue, Apr 28, 2009 at 4:39 PM, Greg Spencer <gspen...@google.com>
>> wrote:
>> > 1) I'd like to add some explicit routines for converting to/from UTF8
>> and
>> > UTF16.  While it's nice (and important) that FilePath uses the
>> platform's
>> > native string, we've found that many third party libraries have made
>> other
>> > assumptions, where they always expect UTF8 (char) or UTF16 (wchar_t)
>> paths
>> > regardless of platform, and converting a FilePath to and from those
>> forms is
>> > a platform-dependent exercise which should be centralized into the class
>> > (i.e. adding "ToUTF8" and "ToWide" functions to the class, and explicit
>> > constructors that take each type).
>>
>> One thing many of us have found, across multiple projects, is that
>> wchar_t is fraught with complication as soon as more than one platform
>> is involved. "wchar_t == UTF16" is a Windowsism (gcc defaults to 4
>> bytes, for example, and L"mumble" gets stored in UCS-4, not UTF-16).
>> Chrome started with more or less what you are suggesting, and we moved
>> off of it after much pain.
>
>
> I understand those issues quite well (but I probably should call the
> conversion method ToUTF16, now that you mention it).  And char* isn't
> necessarily UTF8 on all platforms either.
>
> OK, so what's the currently recommended path for converting to UTF16 or
> UTF8 from a FilePath?
>

The biggest problem with this change is that it's not possible to do this
conversion on Linux in a safe way.  In Linux, there is no charset defined by
the filesystem.  Each filename is just a blob of bytes.  Apps are supposed
to respect an environment variable, but since this environment variable
could change over time and be different from user to user, there's no
reliable way to know what the charset is, so you can't convert from a
FilePath on Linux to UTF8 or UTF16 unless you were the one who created the
path to begin with.

Erik

--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to