use Test::More;
use Text::CharWidth qw(:all);
my $string = " \x{8c61}\x{5f62}\x{6587}\x{5b57}\x{8c61}\x{5f62}\x{6587}\x{5b57} ";
ok utf8::valid($string), "is valid utf8";
is length($string), 10, "There are 10 bytes";
is mbswidth($string), 18, "CharWidth of kanji";
done_testing;
####
$ LC_ALL= prove -l -v t/simple_unicode_test.t
t/simple_unicode_test.t ..
ok 1 - is valid utf8
ok 2 - There are 10 bytes
not ok 3 - CharWidth of kanji
1..3
# Failed test 'CharWidth of kanji'
# at t/simple_unicode_test.t line 9.
# got: '-22'
# expected: '18'
# Looks like you failed 1 test of 3.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/3 subtests
Test Summary Report
-------------------
t/simple_unicode_test.t (Wstat: 256 Tests: 3 Failed: 1)
Failed test: 3
Non-zero exit status: 1
Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.03 sys + 0.03 cusr 0.01 csys = 0.09 CPU)
Result: FAIL
####
$ perl -C63 -MDevel::Peek -Mutf8 -mText::CharWidth=mbswidth -le '$_="(\x{5fcd} Guimarães)"; Dump($_); print mbswidth($_);'
SV = PV(0x8101064) at 0x8100118
REFCNT = 1
FLAGS = (POK,pPOK,UTF8)
PV = 0x814b740 "(\345\277\215 Guimar\303\243es)"\0 [UTF8 "(\x{5fcd} Guimar\x{e3}es)"]
CUR = 16
LEN = 20
14
$ LC_ALL= perl -C63 -MDevel::Peek -Mutf8 -mText::CharWidth=mbswidth -le '$_="(\x{5fcd} Guiarães)"; Dump($_); print mbswidth($_);'
SV = PV(0x8101064) at 0x8100118
REFCNT = 1
FLAGS = (POK,pPOK,UTF8)
PV = 0x814b740 "(\345\277\215 Guimar\303\243es)"\0 [UTF8 "(\x{5fcd} Guimar\x{e3}es)"]
CUR = 16
LEN = 20
6