.NET ez 2011-11-28
判斷字串中是否有非英文及數字的字元,可以用來判斷用戶是否輸入中文字!
/// <summary> /// 判斷字串中是否有非英數文字 /// </summary> public static bool ContainUnicode(string Text) { return (Text.ByteCount() > Text.Length); } /// <summary> /// 取得字串的位元數 /// </summary> public static int ByteCount(this string Text) { return System.Text.Encoding.UTF8.GetByteCount(Text); }
標籤: .NET
本文章網址:
https://www.ez2o.com/Blog/Post/csharp-Analysis-Non-Alphanumeric
https://www.ez2o.com/Blog/Post/2
https://www.ez2o.com/Blog/Post/csharp-Analysis-Non-Alphanumeric
https://www.ez2o.com/Blog/Post/2