Hi!

(All right, I know : me again ;)

So here is what I need to do : I have to modify some registry keys. The name of the key to modify is entered by the user (it really needs to be). Unfortunately, in some cases the name of the key contains French accent. I have been making quick tests using Win32::TieRegistry and Encode. Here is one of them :

use Encode; use Win32::TieRegistry; # #my @allencodings = Encode->encodings(":all"); #print join("\n", @allencodings); my $val; my $val_en; print "Enter a name with French accent:\n"; $val_en = encode("utf8", <STDIN>); chomp $val_en; #registry to modify (depends on program version my $reg = "HKEY_LOCAL_MACHINE/SOFTWARE/"; $val = decode("utf8",$val_en); #sets the delimiter to / for the registry reading and writing $Registry->Delimiter("/"); $testKey = $Registry->{$reg}; #structure of the registry %hashReg = ("Applications" => {"$val" => {"1.8" =>{"Directories" => {"Config" => "test"}}}}); $testKey->StoreKey("Compagnie/", \%hashReg); print "\nDone!";


If I print the value decode $val instead of using it in the registry, it works fine. For example if I enter "tiré" this is what is going to be printed on the screen. But, in the registry I have this "tirÂ," which is quite different.

I have tried different decoding, but so far none worked. So I was wondering if somebody knew how to transfer the French accent into the registry.


In reply to French Accent in Windows Registry by duc

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.