CSharp examples for System:String ASCII
Determine whether is absolute contain ASCII only.
using System.Text.RegularExpressions; using System.Text; using System.Data; using System;//from w w w . ja v a2s . co m public class Main{ /// <summary> /// Determine whether is absolute contain ASCII only. /// </summary> /// <param name="as_body"></param> /// <returns></returns> public static bool IsASCII(string as_body) { Encoding encoding1 = Encoding.Unicode; Encoding encoding2 = Encoding.ASCII; byte[] buffer1 = encoding1.GetBytes(as_body); byte[] buffer2 = Encoding.Convert(encoding1, encoding2, buffer1); char[] chArray1 = new char[encoding2.GetCharCount(buffer2, 0, buffer2.Length)]; encoding2.GetChars(buffer2, 0, buffer2.Length, chArray1, 0); string text1 = new string(chArray1); if (as_body.Equals(text1)) return true; else return false; } }