Skip to content

Instantly share code, notes, and snippets.

@davel
Created January 20, 2012 10:50
Show Gist options
  • Save davel/1646675 to your computer and use it in GitHub Desktop.
Save davel/1646675 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
my $foo = chr(0xff);
is(length($foo), 1, "character length of string is 1");
ok(!utf8::is_utf8($foo), "string not utf-8 upgraded");
use bytes;
is(length($foo), 2, "after use bytes, character length is 2, if UTF-8 upgraded");
no bytes;
is(utf8::upgrade($foo), 2);
ok(utf8::is_utf8($foo), "string utf-8 upgraded");
use bytes;
is(length($foo), 2, "after use bytes, character length is 2, if UTF-8 upgraded");
no bytes;
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment