Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Counting text with ligatures

by hippo (Abbot)
on Sep 13, 2017 at 14:01 UTC ( #1199308=note: print w/replies, xml ) Need Help??


in reply to Counting text with ligatures

How do I get $len as 1 in this example?

Works for me:

$ cat lig.t
use strict;
use warnings;
use utf8;

use Test::More tests => 1;
my $char = "ffi";
my $len = length($char);
is ($len, 1);
$ perl lig.t
1..1
ok 1
$ perl -v

This is perl 5, version 20, subversion 3 (v5.20.3) built for x86_64-linux-thread-multi
(with 16 registered patches, see perl -V for more detail)

If you are working with these sorts of characters you could do a lot worse than go through the length() miscounting UTF8 characters? thread.

Replies are listed 'Best First'.
Re^2: Counting text with ligatures
by albert (Monk) on Sep 13, 2017 at 14:04 UTC
    Thanks for point to this thread. I knew there would be something similar, but didn't get the right search.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1199308]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2017-11-25 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (355 votes). Check out past polls.

    Notices?