Преглед на файлове

[syntax] treat \x escapes as uchars

closes #7449
Simon Krajewski преди 7 години
родител
ревизия
1ba7d2a3cf
променени са 3 файла, в които са добавени 10 реда и са изтрити 3 реда
  1. 2 2
      src/core/ast.ml
  2. 1 1
      tests/unit/src/unit/TestResource.hx
  3. 7 0
      tests/unit/src/unit/issues/Issue7449.hx

+ 2 - 2
src/core/ast.ml

@@ -515,8 +515,8 @@ let unescape s =
 					Buffer.add_char b c;
 					inext := !inext + 2;
 				| 'x' ->
-					let c = (try char_of_int (int_of_string ("0x" ^ String.sub s (i+1) 2)) with _ -> fail()) in
-					Buffer.add_char b c;
+					let u = (try (int_of_string ("0x" ^ String.sub s (i+1) 2)) with _ -> fail()) in
+					UTF8.add_uchar b (UChar.uchar_of_int u);
 					inext := !inext + 2;
 				| 'u' ->
 					let (u, a) =

+ 1 - 1
tests/unit/src/unit/TestResource.hx

@@ -18,7 +18,7 @@ class TestResource extends Test {
 		eq( haxe.Resource.getString("re/s?!%[]))(\"'1.txt"), STR );
 		#if (neko || php ||  eval)
 		// allow binary strings
-		eq( haxe.Resource.getBytes("re/s?!%[]))(\"'1.bin").sub(0,9).toString(), "MZ\x90\x00\x03\x00\x00\x00\x04" );
+		eq( haxe.Resource.getBytes("re/s?!%[]))(\"'1.bin").sub(0,9).toHex(), "4d5a90000300000004" );
 		#else
 		// cut until first \0
 		eq( haxe.Resource.getString("re/s?!%[]))(\"'1.bin").substr(0,2), "MZ" );

+ 7 - 0
tests/unit/src/unit/issues/Issue7449.hx

@@ -0,0 +1,7 @@
+package unit.issues;
+
+class Issue7449 extends unit.Test {
+	function test() {
+		eq(220, "\xDC".charCodeAt(0));
+	}
+}