Demo entry 6703417

iodsaodjsao

   

Submitted by Jelly on Jan 29, 2018 at 01:56
Language: C#. Code size: 710 Bytes.

        private static string Unicode16toASCII(string uStr)
        {
            Regex Re = new Regex(@"\\u(\S{2})(\S{2})");
            MatchCollection matchs = Re.Matches(uStr);
            foreach (Match match in matchs)
            {
                var group = match.Groups;
                if (uStr.IndexOf(group[0].Value) >= 0)
                {
                    byte[] uByte = new byte[2];
                    uByte[0] = Convert.ToByte(group[2].Value, 16);
                    uByte[1] = Convert.ToByte(group[1].Value, 16);
                    uStr = uStr.Replace(group[0].Value, Encoding.Unicode.GetString(uByte));
                }
            }
            return uStr;
        }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).