LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-26-2005, 06:30 AM   #1
fvgestel
LQ Newbie
 
Registered: Oct 2005
Location: Netherlands
Posts: 21

Rep: Reputation: 15
perl pack function


Hi all,

I've stumbled upon a weird problem in perl and I was hoping that some perl-guru here could come with an answer.
The problem is this :
2 years ago I wrote a perl-script which uses the pack function like this :

my $msg = pack("C*",0x80,0x10, 0x29)

now $msg contains 0x80,0x10 and 0x29

I'm running the same code on a redhat enterprise linux ws3 machine with Intel Xeon, only now $msg contains 0xC2,0x80,0x10 and 0x29

It seems that every byte bigger than 0x7F gets a prefix byte! (0xC2 or 0xC3)
What's happening here?
 
Old 10-26-2005, 10:19 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
What does
Code:
pack("C*",0x80,0x10,0x29,0x0);
give you?

I'm thinking there is some kind of boundary alignment issue.
 
Old 10-27-2005, 11:35 AM   #3
fvgestel
LQ Newbie
 
Registered: Oct 2005
Location: Netherlands
Posts: 21

Original Poster
Rep: Reputation: 15
I've already found a solution for my problem. It seems perl looks at the LANG environment variable to convert all IO to utf8 or something like that. I used the binmode function on the socket to prevent convertion.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl and seek() function ivanatora Programming 3 01-28-2005 03:57 AM
what are the Hexadecimal function and ASCII function in Perl Bassam Programming 1 06-03-2004 01:44 AM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM
Perl system function syntax Crashed_Again Programming 2 03-20-2004 04:00 AM
perl opendir like function for php? paulish Programming 2 09-21-2003 03:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration