duc has asked for the wisdom of the Perl Monks concerning the following question:
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 :
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.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!";
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.
|
|---|