Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) 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?

In reply to Re: Directory operations and Unicode by patcat88
in thread Directory operations and Unicode by nikosv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (15)
    As of 2014-09-17 19:16 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (96 votes), past polls