We don't bite newbies here... much | |
PerlMonks |
Re: how to find the length of any line of fileby FreeBeerReekingMonk (Deacon) |
on Nov 24, 2017 at 19:40 UTC ( [id://1204205]=note: print w/replies, xml ) | Need Help?? |
length() by default counts bytes, even if you have multibyte characters (UTF8/unicode) in your file. For unicode lines to be counted correctly you need to open the file you are about to read with "encoding(UTF-8)" and if you want to print it out, you need to use "use utf8;" pragma.
Now it could be your file is encoded in something else than UTF8 (like UTF16), so this might not be your solution yet. See also how-do-i-find-the-length-of-a-unicode-string-in-perl edit note: Edited the response to be more precise, as Choroba suggested.
In Section
Seekers of Perl Wisdom
|
|