Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: error in pr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 11042 of 11531
Post > Topic >>

Re: error in printing unicode

by danmcclory@[EMAIL PROTECTED] (Daniel McClory) May 8, 2008 at 03:21 PM

There are basically 3 lines that you'll want to be using if you're =20
going to be using unicode in your perl scripts - one for input, one =20
for output, and one for using unicode characters within the perl =20
script itself.

binmode STDOUT, ":utf8"; 			#this tells perl that =
the stdout is to be =20
encoded as utf8
open (INPUT, "<:utf8", $ARGV[0]); 	#this tells perl that the input =20=

file is encoded as utf8
use utf8;				#this tells perl that there are =
unicode characters =20
inside the .pl file

so for what you're talking about, you only need to include that line =20
at the beginning of a program, but you might find it helpful to have =20
the other 2, for future reference.

Dan

On May 8, 2008, at 1:32 PM, Vlad Stanimir wrote:

> I just finished reading "Beginning Perl by Simon Cozens Chapter 1: =20
> First Steps In Perl" and i tried to print a Unicode character using =20=

> the \x{} but i got a strange outcome i don't understand.
> The code was:
>
> #!/user/bin/perl
> use warnings;
> print "\x{2620}\n";
>
> and the result was:
>
> Wide character in print at C:\Do***ents and Settings\Vlad\desktop=20
> \test.plx line 3.
> ?=FF=E1
>
> I used windows xp
> cmd.exe
> and i have activeperl 5.10.0 build 1002
>
>
> --=20
> To unsubscribe, e-mail: beginners-unsubscribe@[EMAIL PROTECTED]
> For additional commands, e-mail: beginners-help@[EMAIL PROTECTED]
> http://learn.perl.org/
>
>
 




 3 Posts in Topic:
error in printing unicode
vladbv2006@[EMAIL PROTECT  2008-05-08 20:32:59 
Re: error in printing unicode
danmcclory@[EMAIL PROTECT  2008-05-08 15:21:35 
Re: error in printing unicode
rvtol+news@[EMAIL PROTECT  2008-05-08 22:48:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 19:12:47 CDT 2008.