Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Diiference between these two filenames / strings

by daxim (Curate)
on Sep 13, 2019 at 10:05 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2025-03-27 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (70 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.