Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Simplest Possible Way To Disable Unicode

by JapanIsShinto (Initiate)
on May 24, 2011 at 19:13 UTC ( #906555=note: print w/replies, xml ) Need Help??


in reply to Simplest Possible Way To Disable Unicode

Thanks everyone for your replies. The problem was in my code, specifically that I was at one point in the code generating a character value greater than 255. This was unintentional, and I throw myself at the mercy of the Perl Monks for my transgressions against software engineering.

What led to the solution was the comment someone made about 'chr(999)'. My Unicode-challenged brain saw that and realized that I might accidentally be generating invalid character codes. So I wrote a loop over the string and had it dump out any characters that weren't 0 to 255. And there it was-- I had, essentially, inserted chr(0x4094) in a string I created.

Still, I'm still curious if there is some way I can force Perl into a pre-Unicode state. My guess is that in the past, attempting to give chr() an argument greater than 255 would have resulted in an fatal error (or at least warning) that would have tipped me off to the problem. The advice I've been given here (and the documentation I've read) talks about Unicode support in Perl at different phases-- when reading Perl source code, when reading strings from files opened with a Unicode encoding, when comparing strings and characters, when writing to files, and probably other times as well. So to be clear, what I'd like is the One Ring That Will Rule Them All-- the incantation that tells Perl, "please turn it ALL off."

  • Comment on Re: Simplest Possible Way To Disable Unicode

Replies are listed 'Best First'.
Re^2: Simplest Possible Way To Disable Unicode
by ikegami (Pope) on May 24, 2011 at 19:19 UTC

    Still, I'm still curious if there is some way I can force Perl into a pre-Unicode state.

    There's no way to disable support for wide strings. The closest is use bytes;, but it would have made your error harder to find.

    There's no way to prevent chr(0x4096) from working short of overriding chr.

    $ perl -E' use subs qw( chr ); sub chr(_) { my $ch = CORE::chr($_[0]); $ch lt "\xFF" or die; return $ch; } say chr for 65, 4096; ' A Died at -e line 5.

    My guess is that in the past, attempting to give chr() an argument greater than 255 would have resulted in an fatal error (or at least warning) that would have tipped me off to the problem.

    It did result in a fatal error, and despite being further down the line, the error message was spot on.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2021-04-19 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?