Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: length() miscounting UTF8 characters?

by AppleFritter (Vicar)
on Apr 27, 2014 at 22:42 UTC ( [id://1084057]=note: print w/replies, xml ) Need Help??


in reply to Re: length() miscounting UTF8 characters?
in thread length() miscounting UTF8 characters?

Yes, I'm piping the textfile into the script, though that's more for convenience than anything else. It'd be easy enough to change.

I read up on the open pragma again and noticed that it can be fed another subpragma, :std, to affect the STD* streams:

The :std subpragma on its own has no effect, but if combined with the :utf8 or :encoding subpragmas, it converts the standard filehandles (STDIN, STDOUT, STDERR) to comply with encoding selected for input/output handles. For example, if both input and out are chosen to be :encoding(utf8) , a :std will mean that STDIN, STDOUT, and STDERR are also in :encoding(utf8) .

So I tried changing that line to

use open IO => ':std', ':utf8';

but that didn't make a difference either. I'm probably still missing something fairly obvious.

Thanks for your help, by the way!

Replies are listed 'Best First'.
Re^3: length() miscounting UTF8 characters?
by choroba (Cardinal) on Apr 27, 2014 at 22:51 UTC
    You are almost there.
    use open IO => ':utf8', ':std';

    The order matters.

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Wonderful! That really works - hardly Perl at its dwimmiest, but I'll take what I can get. Thanks so much again!
        You first applied the settings to standard streams, then changed them. I first changed them, then applied the changed settings to the standard streams.
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1084057]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-24 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found