|No such thing as a small change|
Re: Directory operations and Unicodeby patcat88 (Deacon)
|on Nov 06, 2011 at 02:39 UTC||Need Help??|
How would someone use Window's UTF16LE unicode aware APIs with Perl's ASCII until infected with UTF8 string system in XS? I looked for examples of MultiByteToWideChar in perl's source.
1. in win32/win32.c#l815 in perl.git and https://metacpan.org/source/COSIMO/Win32-API-0.60/API.xs#L139 MultiByteToWideChar was set up with "CP_ACP ANSI code page" always.
2. In cpan/Win32/Win32.xs#l161 in perl.git, the SV is checked for utf8 flag, if so its converted as CP_UTF8, otherwise, CP_ACP.
3. or better to force all SVs to utf8 using perl api before MultiByteToWideChar then with CP_UTF8 like in https://metacpan.org/source/BJOERN/Win32-MultiLanguage-0.72/MultiLanguage.xs#L51?
4. Or is it best to leave is to the caller to UTF16LE encode their scalars using Encode and pass "binary garbage" scalars to XS, then nothing but a SvPV, and cast the PV */char * to a wchar_t * the way its done in Win32API::File?
5. use mbstowcs instead of MultiByteToWideChar? mbstowcs uses null string end marking, not exactly safe
6. so far all examples of MultiByteToWideChar, the flags parameter has been zero, except for https://metacpan.org/source/SOMMAR/Win32-SqlServer-2.007/convenience.cpp#L51, where its MB_PRECOMPOSED for ascii and 0 for utf8. Whats the correct handling for the flags parameter of MultiByteToWideChar?