PhantomJS on OS X
OS X 上で次のようなスクリプトを動かすと出力が文字化けした。
var address = "http://UTF-8じゃないコンテンツのURL"; var page = require('webpage').create(); page.open(address, function (status) { console.log(page.plainText); phantom.exit(); });
1.8.1 のソースに https://github.com/zhaolong/phantomjs/commit/ac6599220b73306025c010358510ef7af90e143c を適当に弄って当てたら直った気がする。
diff --git a/src/main.cpp b/src/main.cpp index 734c084..5a0f856 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,6 +37,12 @@ #endif #ifdef Q_OS_MAC #include "client/mac/handler/exception_handler.h" +#include <QtPlugin> +Q_IMPORT_PLUGIN(qcncodecs) +Q_IMPORT_PLUGIN(qjpcodecs) +Q_IMPORT_PLUGIN(qkrcodecs) +Q_IMPORT_PLUGIN(qtwcodecs) +Q_IMPORT_PLUGIN(qico) #endif #include <QApplication> diff --git a/src/phantomjs.pro b/src/phantomjs.pro index c3c915d..3159d63 100644 --- a/src/phantomjs.pro +++ b/src/phantomjs.pro @@ -106,6 +106,12 @@ mac { CONFIG -= app_bundle # Uncomment to build a Mac OS X Universal Binary (i.e. x86 + ppc) # CONFIG += x86 ppc + QTPLUGIN += \ + qcncodecs \ + qjpcodecs \ + qkrcodecs \ + qtwcodecs \ + qico } win32-msvc* { diff --git a/src/qt/preconfig.sh b/src/qt/preconfig.sh index f42989e..befa1ac 100755 --- a/src/qt/preconfig.sh +++ b/src/qt/preconfig.sh @@ -108,3 +108,12 @@ export MAKEFLAGS=-j$COMPILE_JOBS ./configure -prefix $PWD $QT_CFG make -j$COMPILE_JOBS + +cd src/plugins/codecs +make -j$COMPILE_JOBS +cd ../../.. + +cd src/plugins/imageformats +make -j$COMPILE_JOBS +cd ../../.. +
もしかしたら元のパッチそのままでも大丈夫なのかもしれない(ちゃんと試してない)。
追記(2013/04/19): 新しいプルリクエストを出している方がいた。
追記(2013/04/26): 件のプルリクエストがマージされていた!
追記(2013/06/12): 1.9.1 に取り込まれていた。ありがたや。