Tuesday, December 23, 2008

XML::Simple & utf-8

將 DSpace 的資料轉到 Excel ,先匯出 Dublin Core 格式的資料:

dsrun org.dspace.app.itemexport.ItemExport -t COLLECTION -n id -d director

其中 id 是從資料庫中找出的,跟網址列上的 handle id 不同。然後寫個程式將此 XML 格式轉到 HTML,原先用 XML::Simple 模組來讀取 XML 格式的 Dublin Core 資料,可是有些資料出現下列的錯誤訊息:

utf8 "\xB8" does not map to Unicode at ...

然後有些欄位出現部分亂碼,在 CentOS 5+Perl 5.8.8 和 WXP+ActivePerl 5.10.0 build 1003 都出現亂碼。後來在 5.10.0 使用 XML::Twig 模組,不需要 utf8::decode 也不會出現亂碼,處理 XML::Simple 抱怨有問題的資料也跟在 DSpace 網頁上看到的一樣。


No comments: