5

The phantomjs outputEncoding.js example doesn't display the right characters (danish characters)...

I'm running phantomjs 1.7 on windows.

(This used to work when I was running phantomjs 1.4 on linux but also gives an error on linux after updating to the 1.8.2 version)

outputEncoding.js:

function helloWorld() {
        console.log(phantom.outputEncoding + ": æøå");
}

console.log("Using default encoding...");
helloWorld();

console.log("\nUsing other encodings...");

var encodings = ["euc-jp", "sjis", "utf8", "System"];
for (var i = 0; i < encodings.length; i++) {
    phantom.outputEncoding = encodings[i];
    helloWorld();
}

phantom.exit();

result from console:

output from console

Any help is really appreciated!

Thanks.

a_b
  • 1,828
  • 5
  • 23
  • 37
  • Have you found anything to solve the problem since then? – Jérôme Jun 28 '13 at 22:52
  • 2
    hey, its been a while, but I believe the problem was because of the character encoding in the windows cmd. see http://stackoverflow.com/questions/1259084/what-encoding-code-page-is-cmd-exe-using – a_b Jun 29 '13 at 07:17
  • Actually I am running Linux but you helped me in finding this : http://perlgeek.de/en/article/set-up-a-clean-utf8-environment – Jérôme Jul 01 '13 at 10:58
  • indeed as @2083 mentioned, running a `child_process` to invoke `chcp.com` on windows to switch the command line process' code page to unicode 65001 did the trick. – Roberto Andrade Mar 19 '19 at 23:40

0 Answers0