Click here to get back home

bytes and characters - how to decode?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
bytes and characters - how to decode? Panchal V 08-21-2004
Posted by Panchal V on August 21, 2004, 2:19 am
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Posted by Tassilo v. Parseval on August 21, 2004, 11:34 am
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Similar ThreadsPosted
How do I parse certain "bits" out of bytes? May 4, 2005, 12:46 am
Converting 4 bytes to a float May 8, 2007, 8:35 pm
high and low bytes of a decimal May 20, 2008, 12:28 pm
assembling a signed integer from bytes January 8, 2005, 1:54 pm
Matching a variable number of bytes April 13, 2006, 1:31 pm
Archive::Zip problem - bytes being added/changed by zip->contents() July 4, 2006, 4:17 am
Adding a delimiter inbetween number characters and letter characters January 12, 2005, 9:25 am
FAQ 9.16: How do I decode a CGI form? November 11, 2004, 6:03 am
FAQ 9.16: How do I decode a CGI form? November 25, 2004, 12:03 am
FAQ 9.16 How do I decode a CGI form? March 17, 2005, 12:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap