LINUX.ORG.RU

История изменений

Исправление gh0stwizard, (текущая версия) :

1. http://search.cpan.org/perldoc?Encode

1.1 Проверка:

$octets = encode_utf8($string);

Equivalent to $octets = encode(«utf8», $string). The characters in $string are encoded in Perl's internal format, and the result is returned as a sequence of octets. Because all possible characters in Perl have a (loose, not strict) UTF-8 representation, this function cannot fail.

Но тебе нужно следующее:

$string = decode_utf8($octets [, CHECK]);

Equivalent to $string = decode(«utf8», $octets [, CHECK]). The sequence of octets represented by $octets is decoded from UTF-8 into a sequence of logical characters. Because not all sequences of octets are valid UTF-8, it is quite possible for this function to fail. For CHECK, see «Handling Malformed Data».

Смотрим, что ставить в CHECK, тебе подойдет это:

I<CHECK> = Encode::FB_CROAK ( == 1)

If CHECK is 1, methods immediately die with an error message. Therefore, when CHECK is 1, you should trap exceptions with eval{}, unless you really want to let it die.

2. Матчасть:

2.1. http://perldoc.perl.org/Encode.html

2.2. О кодировках в регепсах: http://perldoc.perl.org/perlre.html

Исправление gh0stwizard, :

1. http://search.cpan.org/perldoc?Encode

1.1 Проверка:

$octets = encode_utf8($string);

Equivalent to $octets = encode(«utf8», $string). The characters in $string are encoded in Perl's internal format, and the result is returned as a sequence of octets. Because all possible characters in Perl have a (loose, not strict) UTF-8 representation, this function cannot fail.

Но тебе нужно следующее:

$string = decode_utf8($octets [, CHECK]);

Equivalent to $string = decode(«utf8», $octets [, CHECK]). The sequence of octets represented by $octets is decoded from UTF-8 into a sequence of logical characters. Because not all sequences of octets are valid UTF-8, it is quite possible for this function to fail. For CHECK, see «Handling Malformed Data».

Смотрим, что ставить в CHECK, тебе подойдет это:

I<CHECK> = Encode::FB_CROAK ( == 1)

If CHECK is 1, methods immediately die with an error message. Therefore, when CHECK is 1, you should trap exceptions with eval{}, unless you really want to let it die.

2. Матчасть:

2.1. http://perldoc.perl.org/Encode.html

2.2. О кодировках в регепсах: http://perldoc.perl.org/perlre.html#Which-character-set-modifier-is-in-effect?

Исправление gh0stwizard, :

1. http://search.cpan.org/perldoc?Encode

1.1 Проверка:

$octets = encode_utf8($string);

Equivalent to $octets = encode(«utf8», $string). The characters in $string are encoded in Perl's internal format, and the result is returned as a sequence of octets. Because all possible characters in Perl have a (loose, not strict) UTF-8 representation, this function cannot fail.[/quoute]

Но тебе нужно следующее:

$string = decode_utf8($octets [, CHECK]);

Equivalent to $string = decode(«utf8», $octets [, CHECK]). The sequence of octets represented by $octets is decoded from UTF-8 into a sequence of logical characters. Because not all sequences of octets are valid UTF-8, it is quite possible for this function to fail. For CHECK, see «Handling Malformed Data».

Смотрим, что ставить в CHECK, тебе подойдет это:

I<CHECK> = Encode::FB_CROAK ( == 1)

If CHECK is 1, methods immediately die with an error message. Therefore, when CHECK is 1, you should trap exceptions with eval{}, unless you really want to let it die.

2. Матчасть:

2.1. http://perldoc.perl.org/Encode.html

2.2. О кодировках в регепсах: http://perldoc.perl.org/perlre.html#Which-character-set-modifier-is-in-effect?

Исходная версия gh0stwizard, :

1. http://search.cpan.org/perldoc?Encode

1.1 Проверка:

$octets = encode_utf8($string);

Equivalent to $octets = encode(«utf8», $string). The characters in $string are encoded in Perl's internal format, and the result is returned as a sequence of octets. Because all possible characters in Perl have a (loose, not strict) UTF-8 representation, this function cannot fail.[/quoute]

Но тебе нужно следующее:

$string = decode_utf8($octets [, CHECK]);

Equivalent to $string = decode(«utf8», $octets [, CHECK]). The sequence of octets represented by $octets is decoded from UTF-8 into a sequence of logical characters. Because not all sequences of octets are valid UTF-8, it is quite possible for this function to fail. For CHECK, see «Handling Malformed Data».

Смотрим, что ставить в CHECK, тебе подойдет это:

I<CHECK> = Encode::FB_CROAK ( == 1)

If CHECK is 1, methods immediately die with an error message. Therefore, when CHECK is 1, you should trap exceptions with eval{}, unless you really want to let it die.

Матчасть:

1. http://perldoc.perl.org/Encode.html

2. О кодировках в регепсах: http://perldoc.perl.org/perlre.html#Which-character-set-modifier-is-in-effect?