#!/usr/bin/perl use strict; use warnings; use Devel::Peek; use Encode; #use utf8; binmode STDOUT, ":utf8"; my $string1 = "123\x{444}\x{444}\x{444}\x{444}"; _display ($string1, 'STRING1' ); my $utfstring = "123 \x{439}\x{439}\x{439}\x{439}"; _display ($utfstring, 'UTF_STRING' ); my ($ascii_but_utf, undef) = split ' ', $utfstring; _display ($ascii_but_utf, 'ASCII_BUT_UTF' ); #my $bytestring = encode ("UTF-8", "\x{444}\x{444}\x{444}\x{444}"); my $bytestring = "\x{444}\x{444}\x{444}\x{444}"; _display ($bytestring, 'BYTESTRING' ); my $mixedstring = "$ascii_but_utf$bytestring"; # simulate The Unicode Bug here _display ($mixedstring, 'MIXEDSTRING' ); print "MIXEDSTRING and STRING1 are supposed to be identical...\n"; exit; ############### sub _display { my ($string, $name) = @_; print "$name:\n"; Dump $string; my $l1 = length($string); my $l2 = bytes::length($string); if ($l1 != $l2) { print "LENGTHs DIFFERS: length: $l1, bytes: $l2\n" } print "UTF IS ON\n" if utf8::is_utf8($string); print "\n"; }