Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Diiference between these two filenames / strings

by daxim (Curate)
on Sep 13, 2019 at 10:05 UTC ( #11106126=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11106126]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2020-09-30 10:49 GMT
Find Nodes?
    Voting Booth?
    If at first I don’t succeed, I …

    Results (160 votes). Check out past polls.