I have tried to make my question a little more specific.

The following code does not do what I expect.

It is intended to:

  • read all hex values in a multibyte encoded file into memory,
  • copy the hex values to a new list,
  • create a new, empty Unicode::String object
  • set the hex values in the unicode object to the parsed hex values
  • open an output file for writing
  • print the Unicode object to the output file

    so basically it is similiar in nature to a plain old copy.

    use Unicode::String; $o_in = 'in.txt'; $o_out = 'out.txt'; # get the input data into utf16 objects open ( F, $o_in ) || die; while (<F>) { push ( @raw, utf16($_)); } close (F) || die; # get a list of hex values for the data map { push (@hexout, $_->hex) } @raw; # now create an empty utf16 object Unicode::String->stringify_as( 'utf16' ); my $outo = Unicode::String->new(); # and define its hex values $outo->hex ( join '', @hexout); # dump the hex values open ( F, ">$o_out" ) || die; print F $outo; close (F) || die;

    But my input file differs from my output file.

    Does anyone have any idea why?

    Thanks in advance


    In reply to Re: Search and replace in Unicode files by bm
    in thread Search and replace in Unicode files by bm

    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.