Rakefileのshでarg有りのコマンドを実行した時に文字化け(コマンドプロンプト)
こんな感じのファイルを用意。
task :sh do sh "node sh.js ん゛ぁ゛ぁ゛あ゛あ゛" end
sh.js
console.log(process.argv[2]);
rake sh
を実行すると文字化けが起きる。
>rake sh node sh.js ん゛ぁ゛ぁ゛あ゛あ゛ 繧薙・縺√・縺√・縺ゅ・縺ゅ・
.encode(Encoding::Windows_31J)を付けてあげる
Rakefileを変更。
task :sh do sh "node sh.js や゛っ゛た゛ぁ゛あ゛あ゛!゛".encode(Encoding::Windows_31J) end
>rake sh node sh.js や゛っ゛た゛ぁ゛あ゛あ゛!゛ や゛っ゛た゛ぁ゛あ゛あ゛!゛