http://qs1969.pair.com?node_id=317503


in reply to simple file question, extra spaces, win32

I see
| ■U R L R e p o r t |
and those spaces are ascii zero, not spaces, it seems
local $, = ' '; print map { ord $_ } split //, $row;
generates
255 254 85 0 82 0 76 0 32 0 82 0 101 0 112 0 111 0 114 0 116 0
I will look into the Unicode module...

Thanks for the tip about the moon -- I knew this whole problem involved aliens. At least it isn't the Black Helicopters -- those are very scary.

Replies are listed 'Best First'.
Re: Re: simple file question, extra spaces, win32
by SavannahLion (Pilgrim) on Dec 29, 2003 at 19:31 UTC
    Just so you know, the first two bytes (255 254) is a FFFE byte code marker for unicode. It tells whatever is reading the file that it's a Unicode file and what order the bytes are in. For example, if it was FEFF then it would be in Big Endian order where the sequence of 0's would be reversed.

    Example: 254 255 0 85 0 82 0 76....

    I was guessing as to what the problem was without looking at the actual file, but since you posted a tidbit from the file, here's a Unicode FAQ, that should help you to understand how Unicode works.

    ---
    Is it fair to stick a link to my site here?

    Thanks for you patience.

Re: Re: simple file question, extra spaces, win32
by ysth (Canon) on Dec 30, 2003 at 03:12 UTC
    What you want is not the Unicode module (is there one?) but the Encode module:
    use Encode; $utf16_row = v255.254.85.0.82.0.76.0.32.0.82.0.101.0.112.0.111.0.1 14.0.116.0; # fake up your data. $utf8_row = decode("utf16", $utf16_row); print $utf8_row;
    untested