CSharp examples for System.Globalization:Chinese
Is String In GBK
using System.Text; using System;/*from w w w.java 2 s .co m*/ public class Main{ public static bool IsInGBK(string str) { if ((str == null) || (str == "")) { return false; } for (int i = 0; i < str.Length; i++) { if (!IsInGBK(str[i])) { return false; } } return true; } public static bool IsInGBK(char c) { byte[] bytes = gbkEncoding.GetBytes(new char[] { c }); if (((bytes.Length == 2) && (0x81 <= bytes[0])) && ((bytes[0] <= 0xfe) && (0x40 <= bytes[1]))) { return (bytes[1] <= 0xfe); } return false; } }