Printing raw characters?

E

Eduardo

Hi, I need to send a very simple control string to a device. I have
the proper sequence stored in a file:
[root@blah cgi-bin]# od -bc fiscal2.txt
0000000 015 012 230
\r \n 230
0000003

I'm using perl v5.8.0 on a RH9 machine. When I try to print that
sequence, I get the last octal char converted to what I think is
UTF-16:
[root@blah cgi-bin]# perl -e 'print "\r\n\230"' | od -bc
0000000 015 012 302 230
\r \n 302 230
0000004

Do I need to circumvent UTF-16 locale conversion?
How to get it right? Thank you in advance!
 
B

Ben Morrow

I'm using perl v5.8.0 on a RH9 machine. When I try to print that
sequence, I get the last octal char converted to what I think is
UTF-16:
[root@blah cgi-bin]# perl -e 'print "\r\n\230"' | od -bc
0000000 015 012 302 230
\r \n 302 230
0000004

utf8.

[side issue: why are you testing things as root?]
Do I need to circumvent UTF-16 locale conversion?
How to get it right?

Perl is outputting utf8 because you have a UTF8 locale set. You have
three options:

1. Change your locale.
2. Upgrade to >=5.8.1, where this behaviour was removed.
3. perl -e'binmode STDOUT; print "\r\n\230"'

This should *really* go in a FAQ...

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,142
Messages
2,570,820
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top