GetBytes() public method

public GetBytes ( char chars ) : byte[]
chars char
return byte[]
コード例 #1
0
		// Convert between two encodings.
		public static byte[] Convert (Encoding srcEncoding, Encoding dstEncoding, byte[] bytes)
		{
			if (srcEncoding == null)
				throw new ArgumentNullException ("srcEncoding");

			if (dstEncoding == null)
				throw new ArgumentNullException ("dstEncoding");

			if (bytes == null)
				throw new ArgumentNullException ("bytes");

			return dstEncoding.GetBytes (srcEncoding.GetChars (bytes, 0, bytes.Length));
		}
コード例 #2
-1
		public static byte[] Convert (Encoding srcEncoding, Encoding dstEncoding, byte[] bytes, int index, int count)
		{
			if (srcEncoding == null)
				throw new ArgumentNullException ("srcEncoding");

			if (dstEncoding == null)
				throw new ArgumentNullException ("dstEncoding");

			if (bytes == null)
				throw new ArgumentNullException ("bytes");

			if (index < 0 || index > bytes.Length)
				throw new ArgumentOutOfRangeException ("index");

			if (count < 0 || (bytes.Length - index) < count)
				throw new ArgumentOutOfRangeException ("count");

			return dstEncoding.GetBytes (srcEncoding.GetChars (bytes, index, count));
		}