Pinyin fuzzy query implementation

For example: Fuzzy query class in all surnamed "Li, Liu," the students only need to enter a "L" at the time of the query to query.

 

of PYM = String ""; 
the foreach (char in the PersonName C) 
{ 
IF ((int) C> = 33 is && (int) C <= 126) 
    { 
    		// left as letters and symbols      
    		of PYM c.ToString + = (); 
    } 
    the else 
    { 
    		// consonant phonetic accumulation      
    		of PYM + = GetPYChar (c.ToString ()); 
    } 
} 


///       
        /// take single consonant phonetic character      
        ///       
        single characters to be converted ///      
        /// consonant phonetic      
        public String GetPYChar (String C) 
        { 
            byte [] Array = new new byte [2];  
            Array = System.Text.Encoding.Default.GetBytes (C);
            int I = (Short) (Array [0] - '\ 0') * 256 + ((Short) (Array [. 1] - '\ 0 ')); 
            IF (I <0xB0A1) return "*";
            if (i < 0xB0C5) return "a";
            if (i < 0xB2C1) return "b";
            if (i < 0xB4EE) return "c";
            if (i < 0xB6EA) return "d";
            if (i < 0xB7A2) return "e";
            if (i < 0xB8C1) return "f";
            if (i < 0xB9FE) return "g";
            if (i < 0xBBF7) return "h";
            if (i < 0xBFA6) return "j";
            if (i < 0xC0AC) return "k";
            if (i < 0xC2E8) return "l";
            if (i < 0xC4C3) return "m";
            if (i < 0xC5B6) return "n";
            if (i < 0xC5BE) return "o";
            if (i < 0xC6DA) return "p";
            if (i < 0xC8BB) return "q";
            if (i < 0xC8F6) return "r";
            if (i < 0xCBFA) return "s";
            if (i < 0xCDDA) return "t";
            if (i < 0xCEF4) return "w";
            if (i < 0xD1B9) return "x";
            if (i < 0xD4D1) return "y";
            if (i < 0xD7FA) return "z";
            return "*";
        }

 Simply new alphabet code PYM field used to store the table in the art.

 Fuzzy query unified content of the input converted to lowercase conversion operations (the most convenient) in the sqlserver

    实现sql:Select * from PerSon where PersonName like ('%'+@likeInfo+'%') or PYM like ('%'+LOWER(@likeInfo)+'%')  

Guess you like

Origin www.cnblogs.com/JoeYD/p/12523201.html