THRIFT-3403 Fixed JSON string reader doesn't recognize UTF-16 surrogate pairs
Client: C#
Patch: Phongphan Phuttha <phongphan@acm.org>
This closes #668
diff --git a/lib/csharp/test/JSON/Program.cs b/lib/csharp/test/JSON/Program.cs
index 9823221..f61388a 100644
--- a/lib/csharp/test/JSON/Program.cs
+++ b/lib/csharp/test/JSON/Program.cs
@@ -34,6 +34,7 @@
{
TestThrift2365(); // JSON binary decodes too much data
TestThrift2336(); // hex encoding using \uXXXX where 0xXXXX > 0xFF
+ TestThrift3403(); // JSON escaped unicode surrogate pair support.
}
@@ -78,5 +79,17 @@
var prot = new TJSONProtocol(trans);
Debug.Assert(prot.ReadString() == RUSSIAN_TEXT, "reading JSON with hex-encoded chars > 8 bit");
}
+
+ public static void TestThrift3403()
+ {
+ string GCLEF_TEXT = "\ud834\udd1e";
+ const string GCLEF_JSON = "\"\\ud834\\udd1e\"";
+
+ // parse and check
+ var stm = new MemoryStream(Encoding.UTF8.GetBytes(GCLEF_JSON));
+ var trans = new TStreamTransport(stm, null);
+ var prot = new TJSONProtocol(trans);
+ Debug.Assert(prot.ReadString() == GCLEF_TEXT, "reading JSON with surrogate pair hex-encoded chars");
+ }
}
}