Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Unicode strangeness

by pg (Canon)
on Oct 15, 2005 at 21:50 UTC ( [id://500503]=note: print w/replies, xml ) Need Help??


in reply to Unicode strangeness

Here is one solution:

use strict; use warnings; use charnames ':full'; open(my $fh, ">:raw", "test.plp"); binmode($fh, ":encoding(ucs2le)"); print $fh "\r\n"; close $fh; #test open(PLP,"<:encoding(ucs2le)","test.plp"); my $string; sysread(PLP, $string, 100); printf("0x%02x ", ord($_)) for (split //, $string);

This prints:

0x0d 0x00 0x0a 0x00

Your original problem is due to the fact that there is a :crlf layer, and the sequence between layers.

Replies are listed 'Best First'.
Re^2: Unicode strangeness
by Odud (Pilgrim) on Oct 16, 2005 at 13:46 UTC
    Thanks for that pg. I've gone with your solution. Thanks also to the other monks for their suggestions. The application that I'm producing the file for expects an exact format/sequence of carriage returns and newlines. The C code that I took the basic ideas from just opened the file in bin mode and then output a null byte after every character to make it look as though it was writing Unicode...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://500503]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found