
30th March 2006, 00:59
|
|
Junior Member
|
|
Join Date: Mar 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Perl non-printable chars and unwanted formatting
I have a problem using perl to print certain non-visable characters. Simply put, the code I'm working from appear to assume that the following statement will output one byte.
perl -e 'print "\x90";'
However, filtering with wc -c or redirecting to file shows that the statement is actually producing two bytes. A hex viewer shows that the 2nd byte is the correct 0x90, but it is proceeded by a 0xC2 byte. This also occurs with other non-printable characters, but not with printable characters.
I'm quite new to both linux and perl so I'm not sure whether I'm doing something wrong here or whether I've just misunderstood the purpose of the original program. All the web searches and perl reference texts appear to show that the statement is correct and only one byte should be output. Is this extra byte some kind of formatting byte ?
I'm using Redhat 9 and using perl in a bash shell running in a terminal window.
I would appreciate it if anyone could help with this.
Thanks.
|

30th March 2006, 16:56
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
|
|
Did you try single quotes?
Code:
perl -e 'print \'\x90\';'
|

30th March 2006, 17:37
|
|
Junior Member
|
|
Join Date: Mar 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Falko,
The single quotes don't appear to work. The shell just displays the > prompt
I'd be interested to know whether the following statement outputs 1 or 2 on your system (It produces 2 on mine) ?
perl -e 'print "\x90";' | wc -c
Regards,
S
|

31st March 2006, 12:49
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
|
|
Code:
test:~# perl -e 'print "\x90";' | wc -c
1
|

1st April 2006, 21:30
|
|
Junior Member
|
|
Join Date: Mar 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Falko,
I have solved the problem now. My system was using Unicode, which resulted in different codes for non printable characters. By setting the LANG export to en_GB everything works perfectly.
Thanks for your help.
Regards,
S
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 01:09.
|
Recent comments
16 hours 36 min ago
21 hours 52 min ago
22 hours 3 min ago
22 hours 11 min ago
23 hours 13 min ago
1 day 1 hour ago
1 day 3 hours ago
1 day 4 hours ago
1 day 4 hours ago
1 day 5 hours ago