Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I generate binary data from my Perl scripts. I do this by building up strings of yummy data that range from characters 0x00 to 0xFF. And I've been doing this for years without any problem.

Then, I get the bright idea to upgrade my Perl, and with it, I magically enter the world of Unicode. Maybe Unicode is great. Maybe one day it will make sense to me, and I'll appreciate it in all it's glory.

But not right now, please. Right now, I just want my scripts to work just like they worked in the past. Yeah, I'm sometimes on Windows and have to binmode() things. I'm used to that. But now when I do that, I get this:

Wide character in syswrite at ...

I start to read and... OH MY GOD, IT'S FULL OF STARS. Or at least endless documentation that I'm sure is terribly fascinating, but which doesn't get me any closer to doing what I want.

So please, take pity on me. There must be some incantation I can put in my scripts that tells Perl that I want to pretend-- even if it's just for a little while-- that Unicode doesn't exist and I'm back in 2005 when life felt simpler.

Alternatively, knowing that I have code that merrily does things like this...

my $image = chr(0xff) . pack('cN', $someThing, $otherThing);

... is there some minimally-invasive way to wrap the generation of such binary data so that when I syswrite it, I get good old-fashioned binary data out?


In reply to Simplest Possible Way To Disable Unicode by JapanIsShinto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found