Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I have some code to modify a *.INI file on WinXP which is in UTF16. And it seems to work. But when I open said modified copy in either Notepad or TextPad it displays with the null chars as whitespace.

Anybody know what is up with that?

Please tell me it is not one of those wretched registry entries which is needed. Or if it is, please give very specific details how to handle it...or an example.

I'm writing this mostly for other folks to use on WinXP. And even though I do have WinXP at work and on one of my laptops, I'm basically a NetBSD guy. Start in with the MS-speak and I'll be totally lost. Thanks for being compassionate to an outsider.

use PerlIO::encoding; # Modify a copy of a file... sub foo { my $thing_to_do_ref = shift; my @lines; if (open IN, "<", "$some_path") { binmode IN, ":encoding(UTF-16LE)"; while ( my $a_line = <IN> ) { # Do stuff to $a_line... } push @lines, $a_line; } close IN; if (open OUT, ">", "$some_other_path") { binmode OUT, ":encoding(UTF-16LE)"; while (@lines) { my $line = shift @lines; print OUT "$line\n"; } close OUT; } else { print "Oops! Could not write: $! \n"; } } else { print "Oops! Could not read: $! \n"; } }

In reply to UTF-16 on WinXP written by Perl shows whitespaces. by aplonis

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 or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2021-06-15 01:20 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (66 votes). Check out past polls.