This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
sv.c:sv_pos_u2b: Don’t cache anything on magical SVs
[perl5.git] / t / op / utf8magic.t
CommitLineData
b1f58cbd
RGS
1#!perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8
9plan tests => 4;
10
76f73021 11use strict;
76f73021 12
13my $str = "\x{99f1}\x{99dd}"; # "camel" in Japanese kanji
14$str =~ /(.)/;
15
16ok utf8::is_utf8($1), "is_utf8(unistr)";
17scalar "$1"; # invoke SvGETMAGIC
18ok utf8::is_utf8($1), "is_utf8(unistr)";
19
20utf8::encode($str); # off the utf8 flag
21$str =~ /(.)/;
22
23ok !utf8::is_utf8($1), "is_utf8(bytes)";
24scalar "$1"; # invoke SvGETMAGIC
25ok !utf8::is_utf8($1), "is_utf8(bytes)";