Is Chinese Character : Encoding « Internationalization I18N « C# / C Sharp






Is Chinese Character

        


using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Kenly.ChineseSegment.Core
{
    internal static class Utility
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool IsValidFile(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return false;
            }

            if (!System.IO.File.Exists(filePath))
            {
                return false;
            }

            return true;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static bool IsChinese(string text)
        {
            string regExpression = "[\u4e00-\u9fa5]";
            return Regex.IsMatch(text, regExpression);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static bool IsLetter(string text)
        {
            string regExpression = "[a-z|A-Z]";
            return Regex.IsMatch(text, regExpression);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public static bool IsNumber(string text)
        {
            string regExpression = "[0-9]";
            return Regex.IsMatch(text, regExpression);
        }
    }
}

   
    
    
    
    
    
    
    
  








Related examples in the same category

1.Encoding Class represents a character encoding.
2.Encoding.ASCII encoding for the ASCII (7-bit) character set.
3.Gets an encoding for the UTF-16 format that uses the big endian byte order.
4.Read a text file saved with Big Endian Unicode encoding
5.Get byte count and max byte count
6.Display only the encodings that have one or more different names
7.Returns an array that contains all encodings.
8.Returns a sequence of bytes that specifies the encoding used.
9.Gets an encoding for the UTF-32 format using the little endian byte order.
10.Gets an encoding for the UTF-8 format.
11.Gets the Windows operating system code page that most closely corresponds to the current encoding.
12.Petscii Decoder
13.Petscii Encoder
14.extends System.Text.Encoding to create Petscii Encoding
15.SignedLoWord from IntPtr
16.SignedHiWord from IntPtr
17.Pad data to a WORD.
18.Returns the high WORD from a DWORD value.
19.Signed Lo Word
20.Signed Hi Word
21.Flip Endian
22.A Big-endian binary writer.
23.Big-endian binary reader
24.EBCDIC To ASCII