From cfe7718a9d652a3dae31643cd6260b2a649ebac1 Mon Sep 17 00:00:00 2001 From: Ryusei Yamaguchi Date: Wed, 4 Jun 2014 16:41:01 +0900 Subject: [PATCH 1/2] [python] fix haxe.io.Bytes#getString now it deal beyond-BMP (astral) code points correctly. --- std/haxe/io/Bytes.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/std/haxe/io/Bytes.hx b/std/haxe/io/Bytes.hx index d1a20bdcdde..210bf8e6f6a 100644 --- a/std/haxe/io/Bytes.hx +++ b/std/haxe/io/Bytes.hx @@ -287,6 +287,8 @@ class Bytes { try return new String(b, pos, len, "UTF-8") catch (e:Dynamic) throw e; + #elseif python + return python.Syntax.pythonCode("self.b[pos:pos+len].decode('UTF-8')"); #else var s = ""; var b = b; From e60cf902d7bc852ce006c3e93922b5ea68cb36d8 Mon Sep 17 00:00:00 2001 From: Ryusei Yamaguchi Date: Wed, 4 Jun 2014 19:10:29 +0900 Subject: [PATCH 2/2] [python] use 'replace' mode this behavior is as same as C# and Java --- std/haxe/io/Bytes.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/haxe/io/Bytes.hx b/std/haxe/io/Bytes.hx index 210bf8e6f6a..5eb66d35953 100644 --- a/std/haxe/io/Bytes.hx +++ b/std/haxe/io/Bytes.hx @@ -288,7 +288,7 @@ class Bytes { return new String(b, pos, len, "UTF-8") catch (e:Dynamic) throw e; #elseif python - return python.Syntax.pythonCode("self.b[pos:pos+len].decode('UTF-8')"); + return python.Syntax.pythonCode("self.b[pos:pos+len].decode('UTF-8','replace')"); #else var s = ""; var b = b;