Chinese character for 'dog' | 狗 | |
Unicode character number | 72D7 (hex) | 29399 (decimal) |
HTML entity | 狗 | 狗 |
Three bytes in UTF-8 | E7 8B 97 | |
Two bytes in UTF-16 | 72 D7 | |
Two bytes in GB2312 (chinese) | B9 B7 | |
Two bytes in Shift JIS (japanese) | 8B E7 |
use utf8;
use Encode;
$text = decode('UTF-8', $binary);
$binary = encode('UTF-8', $text);
text/plain; charset=US-ASCII
my $entity = MIME::Parser->new()->parse_data($message); my $enc = Encode::find_encoding( $entity->head()->mime_attr('content-type.charset') ); $text = $enc->decode( $entity->bodyhandle()->as_string() );
my $entity = MIME::Entity->build( 'Subject' => Encode::encode('MIME-Header', $subject), 'Data' => Encode::encode('UTF-8', $body), 'Charset' => 'UTF-8', 'Encoding' => '-SUGGEST', ); $entity->as_string();
Content-Type: text/html; charset=ISO-8859-1
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<?xml version="1.0" encoding="ISO-8859-1"?>
<form ... accept-charset="UTF-8">
$binary = HTML::Entities::encode_entities($text)
my $binary = Encode::encode('UTF-8' HTML::Entities::encode_entities($text, '>%lt;&"') );