node.js - Node Webkit - Options for encoding in writeFileSync not work? -
i beginner.
i want write html file containing chinese characters in utf8 encoding. found following code internet.
fs.writefilesync(target, generatehtml(), "utf8");
though when read documentation, didn't explicitly can add encoding flag. generatehtml()
returns html string.
however, following characters "返回" became this: "活動" in file. sure encoding error.
am using wrong function? how can write file in sync using proper utf-8?
edit
the fs.writefilesync
worked alone well, not when content returned function. please try this:
function generatehtml(){return "返回"} fs.writefilesync("index.html", generatehtml(), "utf8");
the file contains ԏ
in utf-8 format, not intended content.
edit
i tested installed node.js version , working properly. seems have node webkit.
i'll include version later. time here not convenient me.
the solution set working node-webkit application page have utf-8 encoding. have add page:
<meta charset="utf-8">
it turns out simple yet i've missed.
Comments
Post a Comment