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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.