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

Re^3: Weird encoding after grabing filenames

by graff (Chancellor)
on Jun 16, 2009 at 20:53 UTC ( #772140=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Weird encoding after grabing filenames
in thread Weird encoding after grabing filenames

When I visited your web page (http://tech-nikos.gr/cgi-bin/test.pl), I was able to get a sensible display by telling my browser to treat the page as iso-8859-7 (greek). But I gather you want the text to be in utf8, which I think would be a good idea.

As you follow moritz's good advice, you have to respect the docs regarding Encode::from_to(). Here's an easy way to do the required loop in a single line of code:

Encode::from_to($_, 'ISO-8859-7', 'utf8') for (@menu_files);
The reason why the path strings are showing up fine is because they are just plain ascii characters; it's only the file names that are non-ascii, and if the web server and browser don't agree on what the encoding is for those non-ascii characters, it's just noise.

(updated to fix grammar in first sentence)


Comment on Re^3: Weird encoding after grabing filenames
Download Code
Re^4: Weird encoding after grabing filenames
by Nik on Jun 17, 2009 at 09:49 UTC
    Thank you very much that was waht i needed.

    Allow me to ask this: Why only the path strings were plain ascii chars and the filenames were non-ascii which lead me to the extra use of Encode::from_to() to show it properly?

    Does it has to do with the way(type of encoding) Vista encoded its filenames? And if this is the case here why encode the folders differently?

      Because some characters are encoded the same in both ISO-8859-7 and UTF-8. So even though you program was buggy, you still happened to get some correct output.

        But the data that actually got prined correctly weren't greek characters. They were data composed of english letters like "/home/nikos/public_html/data/text".

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-09-16 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (4 votes), past polls