Engin0 / gsmmodem

Automatically exported from code.google.com/p/gsmmodem
0 stars 0 forks source link

PDUEncoding->UserData编码和解码方式不一致 #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
get使用的是直接通过char转换,
set使用的是BigEndianUnicode
虽然对于UNICODE码没有问题,但对于不在UNICODE编码范围的字符
(D800-DFFF),结果会不一致。
测试代码如下:
            int high = 0;
            string s1;
            StringBuilder sb = new StringBuilder();
            for (; high < 0x100; high ++)
            {
                s1 = String.Empty;
                sb.Clear();
                int low = 0;
                for (; low < 0x100; low++)
                {
                    sb.Append((char)(low|(high << 8)));
                }
                s1 = sb.ToString();
                _p.UserData = s1;
                string s2 = _p.UserData;
                Assert.AreEqual(s1, s2);//测试到 high = 0xD8 出错
            }

Original issue reported on code.google.com by hiheart...@gmail.com on 6 Dec 2012 at 1:57