Your code does something very silly. You confuse
encode and
decode. I myself confused them for a very long time, and learned the difference only on PerlMonks.
Let's look what you do: at first you encode the string received from terminal into utf8, and then you DECODE IT BACK! So it's again in the encoding of your terminal. So there is no wonder that you can print it back to the terminal, but the Windows Registry of course misinterpretes it.
You need
$val = <STDIN>;
from_to($val, $enc, "UTF-16");
$val = <STDIN>;
from_to($val, $enc, "UTF-16");
where $enc is the encoding of your input data, 'cp1250', i suppose.
$val = <STDIN>;
from_to($val, 'cp850', 'cp1252');
UPDATE: Added the most likely variant according to
tye's note—but it can still be wrong. You need to convert from 'dos' French codepage to 'Windows' French codepage. I inserted the values for Western European codepage.
s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print