camel

���ܤǤ���

[��] Perl �� utf8 �ޤ��Τ��ޤ��ʤ�
�Ƕ��ɤ��Ȥ����ޤ��ʤ����Ȥ��������ǥ����ࡣ
utf8::decode($text) unless utf8::is_utf8($text);

�����������ϡ�Encode::decode_utf8()�Ǥʤ��ȡ�

�ʲ��򤴤�󤯤�������

#!/usr/bin/perl
use strict;
use warnings;
use Encode;
use Devel::Peek;


for my $bytes ( "\x2F", "\xC0\xAF", "\xE0\x80\xAF", "\xF0\x80\x80\xAF" ) {
    my $utf8 = $bytes;
    utf8::decode($utf8) unless utf8::is_utf8($utf8);
    Dump($utf8);
}

������äƤ�������Ǥ��������Ƥ��̤ꡢutf8::decode()�ϡ�������UTF-8�Х�������Ф��Ʋ��⤷�ޤ���

���٤�Encode::decode_utf8()�򸫤Ƥߤޤ��礦��

#!/usr/bin/perl
use strict;
use warnings;
use Encode;
use Devel::Peek;

for my $bytes ( "\x2F", "\xC0\xAF", "\xE0\x80\xAF", "\xF0\x80\x80\xAF" ) {
    my $utf8 = decode_utf8 $bytes;
    Dump($utf8);
 }

���٤�������ʸ���ϡ�����\x{fffd}��REPLACEMENT CHARACTER���֤��������Ƥ��ޤ���

Validation�δ��������ǤϤʤ����ʷ����δ�������⡢Encode::decode_utf8()�Ϥ�������Ǥ������Ǥ� UTF-8 flag ���Ĥ���ʸ����Ϥ��Τޤޥ��ԡ���������ʤΤǡ����ʬ�������פǤ���

#!/usr/bin/perl
use strict;
use warnings;
use Encode;
use Devel::Peek;

{
    use bytes;
    my $bytes = '������';
    Dump($bytes);
    my $utf8 = decode_utf8($bytes);
    Dump($utf8);
}
{
    use utf8;
    my $bytes = '������';
    Dump($bytes);
    my $utf8 = decode_utf8($bytes);
    Dump($utf8);
}

utf8.pm��POD�ˤ⤳������ޤ���

perldoc utf8
$success = utf8::decode($string)

Attempts to convert in-place the octet sequence in UTF-X to the corresponding character sequence. The UTF-8 flag is turned on only if the source string contains multiple-byte UTF-X characters. If $string is invalid as UTF-X, returns false; otherwise returns true.

Note that this function does not handle arbitrary encodings. Therefore Encode is recommended for the general purposes; see also Encode.

utf8::decode()�ϡ����ʸ���󡢤��ʤ�����������ʸ����˸¤ä����Ѥ��٤��Ǥ��礦���������Ϥ�Encode�˿���ޤ��礦��

Dan the Encode Maintainer