duc has asked for the wisdom of the Perl Monks concerning the following question:

Hi!

Here is basically the problem. I have a script which takes arguments from the command line or from the standard input. These arguments are then used to update the windows registry. Most likely, those arguments are to contain French characters. When I simply use :

my $arg1 = <STDIN>;

The sring "Précis" becomes Pr;cis (which is pretty bad since it will affect the registry).

Is there a way to keep the french character the way it was entered? I have look through a couple of forums but I could only find answers related to e-mail subjects... Could it be due to the command shell?

Replies are listed 'Best First'.
Re: Handling French Character input
by Hue-Bond (Priest) on Jul 26, 2006 at 20:13 UTC

    It doesn't matter if it's French or Swahili. What matters is the encoding of the text. There are several modules for dealing with encodings. Encode is part of the core Perl distribution, so you may want to give it a shot. It all boils down to use decode on data that enters your program and then use encode when you're going to let data go outside of the program.

    --
    David Serrano

Re: Handling French Character input
by duckyd (Hermit) on Jul 26, 2006 at 20:41 UTC
    Make sure that you're using the proper encoding when you read (and output) your data. See perldoc -f binmode