作者 | fcamel (飛啊!起舞的小駱駝) | 看板 | P_fcamel |
標題 | [perl] 解決中文輸出入問題, use encoding big5 |
時間 | Thu Aug 12 02:36:00 2004 |
encoding在5.6還未支援, v5.8.0 (v5.7.3?)開始支援,
v5.8.1後支援encoding和utf-8較完整 (v5.8.0的tr///會有問題)
perldoc encoding
perldoc PerlIO
perldoc PerlIO::encoding
可以看到語系IO的說明
perldoc utf8
可以看UTF-8的說明
use encoding big5;
會將STDIN/STDOUT設為big5,
而STDERR和其它用open()開的file handler不會有作用
要使open()後也使用encoding的話, 要在call open時加參數:
SYNOPSIS
open($f, "<:encoding(foo)", "infoo");
open($f, ">:encoding(bar)", "outbar");
$f是file handler, 建議使用大寫字
若對應的IN/OUT沒有用同樣encoding的話, 似乎會有奇妙現象發生
設為big5後, 就不用擔心Regular Expression比對時會誤改中文字,
嗯...大概吧, 這種事沒遇到錯誤時, 怎麼會知道支援的完不完整? ^^"
|