Beispiel #1
0
        public static string Decode(string byteString)
        {
            UTF8.byteArray = UTF8.Ucs2Decode(byteString);
            UTF8.byteCount = UTF8.byteArray.Count;
            UTF8.byteIndex = 0;
            List <int> array = new List <int>();
            int        num;

            while ((num = UTF8.DecodeSymbol()) != -1)
            {
                array.Add(num);
            }
            return(UTF8.Ucs2Encode(array));
        }
Beispiel #2
0
        public static string Encode(string str)
        {
            List <int>    intList       = UTF8.Ucs2Decode(str);
            int           count         = intList.Count;
            int           index         = -1;
            StringBuilder stringBuilder = new StringBuilder();

            while (++index < count)
            {
                int codePoint = intList[index];
                stringBuilder.Append(UTF8.EncodeCodePoint(codePoint));
            }
            return(stringBuilder.ToString());
        }