How to make TS in VS2012 generate UTF-8 JS files?

Topics: General
Apr 24, 2013 at 2:40 PM
Edited Apr 24, 2013 at 2:41 PM
For example, if the *.ts was saved in UTF-8 encoding, the following line:
var canvas = <HTMLCanvasElement>document.getElementById("drawingSurface");
var context = <CanvasRenderingContext2D>canvas.getContext("2d");
context.font = "12px Simsun";
context.fillStyle = "#ffffff";
context.fillText("Chinese Characters 中文文字", 0, 0);
will generate:
var canvas = document.getElementById("drawingSurface");
var context = canvas.getContext("2d");
context.font = "12px Simsun";
context.fillStyle = "#ffffff";
context.fillText("Chinese Characters ????", 0, 0);
It seems TS always generate .js files in current system codepage, regardless what kind of file encoding the .ts is using. The only way to draw that string correctly is set the .ts and .html to system codepage (not an option for me), or read this string from an external source (also not an option, don't ask me why :(

Is there a way to make the compiler generate UTF-8 files?
Apr 24, 2013 at 4:34 PM
The command chcp changes the system codepage. 65001 is the UTF-8 codepage so maybe if you execute chcp 65001 in the build script before compilation happens that will just work?
Apr 25, 2013 at 2:27 AM
Grajkowski wrote:
The command chcp changes the system codepage. 65001 is the UTF-8 codepage so maybe if you execute chcp 65001 in the build script before compilation happens that will just work?
Not working :( , still generate ANSI files.