Loyc.StringBuilderExt.AppendCodePoint C# (CSharp) Method

AppendCodePoint() public static method

Appends a unicode code point in the range 0 to 0x10FFFF to StringBuilder in UTF-16.
Invalid character c null StringBuildre
public static AppendCodePoint ( this s, int c ) : StringBuilder
s this
c int
return StringBuilder
		public static StringBuilder AppendCodePoint(this StringBuilder s, int c)
		{
			if ((uint)c <= 0xFFFF)
				s.Append((char)c);
			else if ((uint)c <= 0x10FFFF)
			{
				c -= 0x10000;
				s.Append((char)((c >> 10) | 0xD800));
				s.Append((char)((c & 0x3FF) | 0xDC00));
			}
			else
				throw new ArgumentOutOfRangeException("Invalid unicode character: {0}".Localized(c));
			return s;
		}
	}