Decode Control Characters - CSharp System

CSharp examples for System:Char

Description

Decode Control Characters

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//w w  w  .  j a va  2  s.  c om

public class Main{
        static string DecodeControlCharacters(string input)
		{
			int i = 0, len = input.Length;
			for (; i < len; i++)
			{
				char c = input[i];
				if (c >= 0xE000 && c < 0xE020)
				{
					break;
				}
			}
			if (i == len)
			{
				return input;
			}
			StringBuilder sb = new StringBuilder();
			if (i != 0) { sb.Append(input, 0, i); }
			for (; i < len; i++)
			{
				char c = input[i];
				if (c >= 0xE000 && c < 0xE020)
				{
					sb.Append((char) (c - 0xE000));
				}
				else
				{
					sb.Append(c);
				}
			}
			return sb.ToString();
		}
}

Related Tutorials