Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
8
Task/String-length/Perl/string-length-1.pl
Normal file
8
Task/String-length/Perl/string-length-1.pl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
use utf8; # so we can use literal characters like ☺ in source
|
||||
use Encode qw(encode);
|
||||
|
||||
print length encode 'UTF-8', "Hello, world! ☺";
|
||||
# 17. The last character takes 3 bytes, the others 1 byte each.
|
||||
|
||||
print length encode 'UTF-16', "Hello, world! ☺";
|
||||
# 32. 2 bytes for the BOM, then 15 byte pairs for each character.
|
||||
1
Task/String-length/Perl/string-length-2.pl
Normal file
1
Task/String-length/Perl/string-length-2.pl
Normal file
|
|
@ -0,0 +1 @@
|
|||
my $length = length "Hello, world!";
|
||||
5
Task/String-length/Perl/string-length-3.pl
Normal file
5
Task/String-length/Perl/string-length-3.pl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
use v5.12;
|
||||
my $string = "\x{1112}\x{1161}\x{11ab}\x{1100}\x{1173}\x{11af}"; # 한글
|
||||
my $len;
|
||||
$len++ while ($string =~ /\X/g);
|
||||
printf "Grapheme length: %d\n", $len;
|
||||
Loading…
Add table
Add a link
Reference in a new issue