Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
pack works for me.
$ use Devel::Peek

$ Dump pack 'A20', "FREIGHT – INTRASTATE"
SV = PV(0x4a5bce0) at 0x4a29660
  REFCNT = 1
  FLAGS = (PADTMP,POK,pPOK,UTF8)
  PV = 0x4644800 "FREIGHT \342\200\223 INTRASTATE"\0 [UTF8 "FREIGHT \x{2013} INTRASTATE"]
  CUR = 22
  LEN = 40
[]
$ open my $fh, '>:encoding(UTF-8)', '/tmp/foobar'
1
$ $fh->print(pack 'A20', "FREIGHT – INTRASTATE")
1

/tmp$ hex /tmp/foobar
0000  46 52 45 49 47 48 54 20  e2 80 93 20 49 4e 54 52  FREIGHT – INTR
0010  41 53 54 41 54 45                                 ASTATE

In reply to Re: pack mangles utf output by daxim
in thread pack mangles utf output by roho

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 learning in the Monastery: (8)
As of 2024-04-23 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found