Win32::TieRegistry only deals with 8-bit-character strings as it uses the *A APIs not the *W APIs. Win32API::Registry exposes the *W APIs, but you'll have to do some extra work to translate the information you give and get1.

Those two registry modules were written before Perl had much of a clue about Unicode. Now that Perl has settled on UTF-8 (or something very close to UTF-8, I hear) and has some decent support for it, it'd be a good idea to update Win32::TieRegistry to take advantage of it, at least optionally.

The script you wrote dies because it (MS's *A API) translates the key name as best it can into your current 8-bit locale. That is, it translates the name into something similar but not the same. So trying to open a key by the translated name finds no match. You don't check for the open failing so when you try to use the return value you get the error you showed.

- tye        

1 The *W APIs use what Microsoft calls "UNICODE", which is really fixed-width 16-bit characters somewhat like UTF-16 except, of course, for it being fixed-width. So it matches UTF-16 so long as you only use characters that can fit in 15 bits. Some will even tell you that UTF-16 is fixed-width. They are just a little confused (UTF-16 "is fixed-width" so long as you only use characters that fit within 15 bits).

If you try to use Unicode characters that require exactly 16 bits, then Microsoft's "UNICODE" will probably set the highest bit while UTF-16 would encode the character into 32 bits (I think). Unicode characters that require more than 16 bits don't fit in Microsoft's "UNICODE" format.

Microsoft also supports UTF-8 which it calls "wide character", but it mostly just lets you translate that into either ASCII or "UNICODE"; it doesn't really provide APIs that deal with it in, for example, file names or registry keys.


In reply to Re: possible perl bug or, at least, Win32::[TieRegistry|Registry] bug with difficult keynames (limitation) by tye
in thread possible perl bug or, at least, Win32::[TieRegistry|Registry] bug with difficult keynames by perl-diddler

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!
  • 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:
    & &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.