| IsUTF8 documentation | view source | Contained in the IsUTF8 distribution. |
IsUTF8 - detects if UTF8 characters are present
use IsUTF8;
$result = IsUTF8::isUTF8;
$result = IsUTF8::isUTF8($line);
use IsUTF8 qw(isUTF8);
$result = isUTF8;
$result = isUTF8($line);
use IsUTF8 qw(isUTF8 debug);
$result = isUTF8;
$result = isUTF8($line);
if (not defined $result) {
print "Contains some characters with 8th bit set!";
}
if ($result == 0) {
print "Plain ASCII (0..127)";
}
if ($result) {
print "Contains UTF8";
}
This tests the given line and returns true if there is at least one
UTF8 character sequence. (Actually the tests returns after the first
sequence found.) undef is returned if there is some other character
with the 8th bit set. 0 is returned if there are only characters
from 0x00 to 0x7f.
UTF8-Encoding looks like this:
1111.0x: 1111.0000-1111.0111 0xF0 - 0xF7, followed by 3 bytes
1110.xx: 1110.0000-1110.1111 0xE0 - 0xEF, followed by 2 bytes
110x.xx: 1100.0000-1101.1111 0xC0 - 0xDF, followed by 1 byte
10xx.xx: 1000.0000-1011.1111 0x80 - 0xBF (following byte as above)
First release. Please do not rely on a stable API yet. If you're interested in stabilizing, please tell me.
Probably. Not tested a lot!
Heiko Schlittermann <hs@schlittermann.de>
| IsUTF8 documentation | view source | Contained in the IsUTF8 distribution. |