in reply to Encoding problem

Welcome, leeericsson.

To assist others in sharing their wisdom with you, could you please post a short example of your code - preferably an example that shows the conversion working for English and Chinese, but not for German.


PS. Also, Please take a few minutes to read these links:
How do I compose an effective node title?
Markup in the Monastery

Replies are listed 'Best First'.
Re^2: Encoding problem
by Anonymous Monk on Jan 18, 2010 at 07:44 UTC
    Hi, Here are my codes ############################
    use Encode;
    $text = @ARGV[0];
    #here i read a string from command line
    $string = decode("gb2312",$text);
    #decode the input with gb2312, which is decided by my local setting
    @chars = split //,$string;
    open(OUTPUT,">>anUTF8File.txt");
    foreach $char (@chars)
    {
    print OUTPUT encode("utf8",$char);
    #i encode it into utf8 here
    #and write it to the utf8 formatted file
    }
    close(OUTPUT);
    ############################
    when I input english string in the command, this works fine. then i changed my keyboard to German type and type some German characters for the ARGV[0], then what was written to the file were some strange characters like "?" or others.
      The problem is with the program that launches perl (and populates @ARGV) and displays the output (?????). On win32 this is usually cmd.exe, and you have to configure cmd.exe separately to accept German type input ( chcp ) and separately to display German properly (font settings).