Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Playing with Unicode
Why when I run this one-liner:

perl -e 'print "\x{2660}\n"'

do I see this:

Wide character in print at -e line 1.

I'm assuming that's a warning, since I still get the expected output,
but why am I getting it, when I didn't ask for them?

Is there a better way to drop in a unicode character?

Semi-related question:  Is there a good document I could read somewhere
on the differences for one-liners in Windows?

Thanks.

James


Report this thread to moderator Post Follow-up to this message
Old Post
James Edward Gray II
03-27-04 04:14 AM


Re: Playing with Unicode
On 3/25/2004 5:42 PM, James Edward Gray II wrote:
> Why when I run this one-liner:
>
> perl -e 'print "\x{2660}\n"'
>
> do I see this:
>
> Wide character in print at -e line 1.
>
> I'm assuming that's a warning, since I still get the expected output,
> but why am I getting it, when I didn't ask for them?
>
> Is there a better way to drop in a unicode character?
>
> Semi-related question:  Is there a good document I could read somewhere
> on the differences for one-liners in Windows?

Hi James,

I'm not really up on unicode, but you might find something in 'perldoc
perluniintro' & 'perldoc perlunicode'.

The only information that I know of about running perl at the
commandline is in 'perldoc perlrun'. Although, I have a vague
recollection of seeing an article with hints and tips for one-liners
somewhere. Maybe a google search will find something.

Regards,
Randy.



Report this thread to moderator Post Follow-up to this message
Old Post
Randy W. Sims
03-27-04 04:15 AM


Re: Playing with Unicode
James Edward Gray II wrote:

> Why when I run this one-liner:
>
> perl -e 'print "\x{2660}\n"'
>
> do I see this:
>
> Wide character in print at -e line 1.
>
> I'm assuming that's a warning, since I still get the expected output,
> but why am I getting it, when I didn't ask for them?
>

different version seems to behave differently. my v5.6.0 never warn me about
it. my v5.8.2 does emit a warning. you can turn it off by saying:

[panda]# perl -mbytes=no -e 'print "\x{2660}\n"'

there is a long discussion about what Perl should do when it encounters a
byte sequence which is different than the current C local. should it
upgrade to UTF-8 silently? should it warn? if the current C local is not
UTF-8 then what? you can check the p5p list for the discussion.

david
--
s$s*$+/<tgmecJ"ntgR"tgjvqpC"vuwL$;$;=qq$
 \x24\x5f\x3d\x72\x65\x76\x65\x72\x73\x65

 \x24\x5f\x3b\x73\x2f\x2e\x2f\x63\x68\x72

 \x28\x6f\x72\x64\x28\x24\x26\x29\x2d\x32

 \x29\x2f\x67\x65\x3b\x70\x72\x69\x6e\x74

 \x22\x24\x5f\x5c\x6e\x22\x3b\x3b$;eval$;



Report this thread to moderator Post Follow-up to this message
Old Post
David
03-27-04 04:15 AM


Re: Playing with Unicode
James Edward Gray II wrote:

> Why when I run this one-liner:
>
> perl -e 'print "\x{2660}\n"'
>
> do I see this:
>
> Wide character in print at -e line 1.

Makes sense.  2660 would overflow a one-byte character.

>
>
> I'm assuming that's a warning, since I still get the expected output,
> but why am I getting it, when I didn't ask for them?
>
> Is there a better way to drop in a unicode character?

I think you need to warn the compiler ahead of time that you are reading or
writig unicode.  It adapts anyway, but it's just reminding you.  You might s
ee
if you can make sense out of
perldoc encoding
perldoc perlunicode
though they are both rather windy and circuituous.

Joseph



Report this thread to moderator Post Follow-up to this message
Old Post
R. Joseph Newton
03-27-04 04:15 AM


Re: Playing with Unicode
On Mar 25, 2004, at 6:54 PM, Randy W. Sims wrote:

> On 3/25/2004 5:42 PM, James Edward Gray II wrote: 
>
> Hi James,
>
> I'm not really up on unicode, but you might find something in 'perldoc
> perluniintro' & 'perldoc perlunicode'.

Thank you, these Documents are great, especially the first one.

If anyone is interested, you silence the warning by setting STDOUT to
Utf-8 output with:

binmode STDOUT, ":utf8";

James


Report this thread to moderator Post Follow-up to this message
Old Post
James Edward Gray II
03-27-04 04:15 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:52 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.