Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Non english characters

by inman (Curate)
on Oct 17, 2005 at 09:47 UTC ( [id://500689]=note: print w/replies, xml ) Need Help??


in reply to Non english characters

Your script is written in a non-UTF8 character set (probably latin1). Your data is written in this character set. When you 'use utf8' Perl tries to interpret the data as UTF8. When it hits the 'é' then it complains since this should be a double byte character.

Have a look at the Encode module. Try out a number of scripts and save the output to a file. If you examine the file using a hex editor you will see the double byte representations of non-ascii characters. The documentation for this module is full of references to UTF8. Also look at perluniintro and friends.

This script takes data from STDIN and writes out the UTF8 converted data to a file.

#! /usr/bin/perl use strict; use warnings; use Encode; open UTF8, '>utf8.txt' or die; while (<>) { my $data = encode("utf8", $_); print UTF8 "$data\n"; } close UTF8;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-29 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found