Closed
Description
[Google Issue #1581 : https://code.google.com/p/haxe/issues/detail?id=1581]
by mwgamera, at 28/02/2013, 20:57:19
The following code should compile without error unless target platform doesn't support \0 in its strings.
class Test { static function main() { var s : String = "\000"; } }
When compiled to js, haxe throws an error:
Test.hx:3: characters 21-27 : A String cannot contain \0 characters
Javascript itself doesn't have any problems with handling \0s natively, the only reason that haxe checks for it in genjs.ml is that it uses Ast.s_escape for emitting literals which doesn't support \0. Other platforms use their own custom escaping routines for this and so should js probably do.
Note that following code works:
class Test { static function main() { var a : String = String.fromCharCode(65); // emitted as literal "A" var z : String = String.fromCharCode(0); // emitted as String.fromCharCode(0) call } }
Activity