Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Remove Double Spacingby theorbtwo (Prior) |
on Jan 28, 2005 at 19:07 UTC ( [id://426079]=note: print w/replies, xml ) | Need Help?? |
Are you sure those are really spaces, and not null bytes? (Try asking Data::Dumper to dump it.) If those are null bytes, the file is in UTF-16, and you're reading it as if it were in latin-1. If you're using perl 5.8, you can simply tell Perl that the file is in utf16: binmode($fh, ':encoding(utf-16)'). If you're under 5.6, it's a hair more complicated -- you need to first read in the data, then use Encode to "decode" it from utf-16 to perl's internal format. $useable=decode('utf-16', $encoded);. Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).
In Section
Seekers of Perl Wisdom
|
|