Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( #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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (8)
    As of 2021-04-21 15:01 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?