http://qs321.pair.com?node_id=11106126


in reply to Diiference between these two filenames / strings

All characters of string 2 are in Latin1, but some characters in string 1 are beyond codepoint 0xff.

I'm making a guess: your program handles decoding not properly, and so you end up with string 2 encoded as Latin1 and string 1 decoded into Perl's internal format, which – when passed into the world outside the program – accidentally does the correct thing.

This explanation fits the symptoms, but since you did not show any code, we can't be sure.

  • Comment on Re: Diiference between these two filenames / strings

Replies are listed 'Best First'.
Re^2: Diiference between these two filenames / strings
by Anonymous Monk on Sep 13, 2019 at 14:23 UTC

    Hi Daxim,

    I think your Hint did the trick.

    Following code suggested by another monk seems working fine for me.

    I have checked below code on filenames in diff languages, like Chinese, Japanese, Danish, polish, Spanish and off-course English.

    use Encode;

    $filename = decode_it($filename);

    $filename = encode('UTF-8', $filename);
    #--------------------------------------- sub decode_it { my $s = shift; eval { $s = decode('UTF-8', $s, 1); 1; } or do { $s = decode('latin1', $s, 1); }; return $s; }

    Thank you. Cheers.