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

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, details, 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, summary, 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.