Asp.net letters, asp.net letters
1. uppercase/lowercase letters
Private string GetChangedStr (string oldStr, strType type) {string newStr = ""; // when using the TextInfo class, you must specify the regional information. In most cases, you can default the currently used culture. CultureInfo culInfo = Thread. currentThread. currentCulture; TextInfo tInfo = culInfo. textInfo; switch (type) {case strType. upper: // convert to newStr = tInfo. toUpper (oldStr); break; case strType. lower: // convert to lowercase newStr = tInfo. toLower (oldStr); break; case strType. firToUpper: // uppercase newStr = tInfo. toTitleCase (oldStr); break; case strType. UTL_LTU: // convert uppercase to lowercase and lowercase to uppercase. Char [] oldArr = oldStr. toCharArray (); for (int I = 0; I <oldArr. length; I ++) {if (char. isUpper (oldStr, I) newStr + = oldArr [I]. toString (). toLower (); else newStr + = oldArr [I]. toString (). toUpper ();} break; default: break;} return newStr;} enum strType {Upper, Lower, FirToUpper, UTL_LTU}
2. Interchange of letters and ASCII
The role of ASCII in Web development! (American Standard Code for Information Interchange, US Standard Code for Information exchange)
For example, 'single quotes are a killer in SQL statements, but if you convert (') to "& #" + ASCII code +, it can effectively prevent SQL injection!
Private string strToASCII (string oldStr) {string newStr = "the parameter cannot be blank !!! "; If (! String. isNullOrEmpty (oldStr) {int num; if (int. tryParse (oldStr, out num) {newStr = (char) num ). toString ();} else {if (Encoding. getEncoding ("unicode "). getBytes (new char [] {oldStr [0]}) [1] = 0) // determines whether it is a letter {newStr = Encoding. getEncoding ("unicode "). getBytes (oldStr) [0]. toString () ;}} return newStr ;}
3. Chinese characters and location codes
In order to make every Chinese character has a unified national code, in 1980, China issued the first Chinese character encoding National Standard: GB2312-80 "information exchange with Chinese character encoding Character Set" basic set, this character set is the Development Basis of Chinese Information Processing Technology in China and also the unified standard of all Chinese character systems in China. Because the country code is in a four-digit hexadecimal format, to facilitate communication, we usually use a four-digit decimal location code.
All Chinese characters and symbols of the national standard form a 94 × 94 matrix. In this square matrix, each row is called a "area", and each column is called a "bit". Therefore, this square matrix actually forms a Chinese character set with 94 areas (0 1 to 94 area numbers respectively) and 94 places (bits are 01 to 94) in each area.
The area code and location code of a Chinese character are simply combined to form the "location code" of the Chinese character ".
In the Chinese character location code, the upper two digits are the area code, and the lower two digits are the bit numbers. In the location code,
The 01-09 zone contains 682 special characters,
16 ~ Area 87 is the Chinese character area, which contains 6763 Chinese characters. Areas 16-55 are primary Chinese characters (3755 most commonly used Chinese characters are listed in the order of Pinyin letters ),
Area 56-87 is a list of second-level Chinese characters (3008 Chinese characters in the order of radicals );
Area 88-94: blank, to be extended.
Private string strToLocCode (string oldStr) {try {string newStr = ""; byte [] btArray = new byte [2]; // defines a byte array for storing Chinese characters btArray = Encoding. default. getBytes (oldStr); // value: int first = (short) (btArray [0]-'\ 0'); int second = (short) (btArray [1]-'\ 0'); newStr = (first-160 ). toString () + (second-160 ). toString (); // calculate the location code return newStr;} catch (Exception e) {return e. message + "enter the correct Chinese characters ";}}
Communication Group: 225443677