2010年9月4日

PAR打包Encode模組時出現找不到編碼問題

我會用Encode模組進行字型編碼轉換,程式碼如下
#!/usr/bin/perl
use Encode;
$instring = "測試";
$outstring = encode('utf8',decode('big5', $instring));
print $outstring;


在沒有用PAR打包時,直接用perl執行程式是沒問題的,一旦打包後卻會出現編碼問題
shell>% pp -o output input.pl
shell>%./output
Unknown encoding 'big5' at script/csv2ldif.pl line 180

解決辦法就是將程式碼改寫一下,加上use Encode::TW就可以解決了。若你不是要用big5編碼,可參閱Encode模組手冊,對照一下就知道要使用哪個編碼。

沒有留言:

張貼留言