[cairo] [PATCH] script: More compatible with C89 and VC++.
spitzak at gmail.com
Thu Jun 24 17:30:06 PDT 2010
Tor Lillqvist wrote:
>> You do not need to
>> translate multibyte characters in order to locate '/' and ':' and '\\'
> The so-called double-byte code pages used in East Asian Windows
> localisations have characters that use two bytes of which the trailing
> one might be '/' or '\\' .
True but is anybody using this any more?
> So one indeed needs to take multibyte characters into consideration
> when scanning a multibyte string for directory separators. Either by
> converting the string to wide characters (UTF-16), or by using
> multi-byte-aware API like _mbschr(), _mbsnextc(), _mbsinc().
I would do the one-character-at-a-time api instead of allocating a
buffer. This will allow you to skip errors in the encoding, it is
probably best to treat errors as the individual bytes unchanged.
>> Translation to w_char and back is lossy so this is not a good idea!
> If you start with a multibyte string, it can be translated to a wide
> string and back without loss.
Not if the multibyte string contains an encoding error!
More information about the cairo