Gem execjs 跟 Win8 的兼容性问题

southwolf · December 13, 2012 · Last by southwolf replied at December 13, 2012 · 4672 hits

刚才调环境发现 execjs 跟 Win8 有点兼容性的小问题。

execjs 现在已经能认到 Windows 自带的 CScript 了 所以 windows 下无需再装 therubyracer 和 nodejs 之类的 JS Runtime

但是 Win8 下 CScript 默认接受 js 编码是 UTF-8, 而之前的 CScript 接受的是 ASCII/GBK, 或者用//U参数后接受 UTF-16,解决方法是

修改 execjs gem 路径下 execjs\runtimes.rb

JScript = ExternalRuntime.new(
    :name => "JScript",
    :command => "cscript //E:jscript //Nologo //U",
    :runner_path => ExecJS.root + "/support/jscript_runner.js",
    :encoding => 'UTF-16LE'
)

改成

JScript = ExternalRuntime.new(
  :name        => "JScript",
  :command     => "cscript //E:jscript //Nologo",
  :runner_path => ExecJS.root + "/support/jscript_runner.js",
   :encoding    => 'UTF-8'
)

这是 patch?可以回馈给上游啊。

southwolf in RailsGirls 要用到的开发环境 [Windows] mention this topic. 03 Apr 10:56
You need to Sign in before reply, if you don't have an account, please Sign up first.