예제 #1
0
        public static void TestThrift2336()
        {
            const string RUSSIAN_TEXT = "\u0420\u0443\u0441\u0441\u043a\u043e\u0435 \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435";
            const string RUSSIAN_JSON = "\"\\u0420\\u0443\\u0441\\u0441\\u043a\\u043e\\u0435 \\u041d\\u0430\\u0437\\u0432\\u0430\\u043d\\u0438\\u0435\"";

            // prepare buffer with JSON data
            byte[] rawBytes = new byte[RUSSIAN_JSON.Length];
            for (var i = 0; i < RUSSIAN_JSON.Length; ++i)
                rawBytes[i] = (byte)(RUSSIAN_JSON[i] & (char)0xFF);  // only low bytes

            // parse and check
            var stm = new MemoryStream(rawBytes);
            var trans = new TStreamTransport(stm, null);
            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");
        }