[cairo] [PATCH] script: More compatible with C89 and VC++.
tml at iki.fi
Thu Jun 24 15:08:01 PDT 2010
> 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 '\\' .
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().
> 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.
Of course, if you start with a wchar_t string containing arbitrary
Unicode, it can't in general be translated to a multibyte string
without loss. (multibyte here meaning some of the possible "system"
codepages; that doesn't include stuff like UTF-8). But I don't think
this was the case here.
More information about the cairo