#!/usr/bin/perl -w use strict; use Encode; use encoding('euc-jp'); binmode(STDERR, ':raw :encoding(euc-jp)'); binmode(STDOUT, ':raw :encoding(utf8)'); my $header = "Content-type:text/html; charset:utf-8\n\n"; print $header; my $str = 'あいうえお'; print "$str\n";
とりあえず、UTF-8で
あいうえお
と表示されました
httpヘッダ
http://hoge.com/utf8.cgi GET /utf8.cgi HTTP/1.1 Host: mydebian User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: ja,en-us;q=0.7,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cache-Control: max-age=0 HTTP/1.x 200 OK Date: Thu, 06 Mar 2008 09:28:10 GMT Server: Apache/2.2.3 (Debian) PHP/5.2.0-8+etch7 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset:utf-8
Perl5.8 utf8フラグ PerlIOレイヤ よく分ってないけど、参考ページ
- UTF8フラグとPerlIOレイヤ :: Perl 5.8.x Unicode関連
- 4. 動的Webページ(CGI)の文字コードをUTF-8にする方法
- Perl 5.8.x における日本語コード変換のメモ
- Perl 5.8 以降においての Unicode 文字列の扱い方 : NDO::Weblog
- Perl の open プラグマと UTF8 フラグの微妙な関係 : NDO::Weblog
- 404 Blog Not Found:perl - utf8::is_utf8("\x{ff}") == 0
- Encode - character encodings - search.cpan.org
- perluniintro - Perl Unicode の手引き