asp.net common string processing method

Source: Internet
Author: User
Tags array net string trim
String Fox;
Fox. ToLower () into lowercase letters
Fox. ToUpper () into uppercase letters
Fox. Trim () Remove space before and after
Fox. Trim (TrimChars) Remove other characters
Fox. TrimStart () Remove before space
Fox. TrimEnd () Delete space after
Fox. PadLeft (10) adds the left space so that the string reaches a certain length.
Fox. PadRight (10) adds the right space so that the string reaches a certain length.
Fox. PADX (10, '-') adds additional characters so that the string reaches a certain length. X means: Left/right
Fox. Split (") to decompose strings into groups

System.Text.Encoding.Default.GetByteCount (Fox); Get string length, one character equals two characters

Acquiring the location code of Chinese characters
byte[] array = new BYTE[2];
Array = System.Text.Encoding.Default.GetBytes ("Ah");

int i1 = (short) (Array[0]-' ");
int i2 = (short) (Array[1]-' ");

Chinese character code under the Unicode decoding method
Array = System.Text.Encoding.Unicode.GetBytes ("Ah");
I1 = (short) (Array[0]-' ");
I2 = (short) (Array[1]-' ");

Unicode reverse decoding to Chinese characters
String str = "4a55";
string S1 = str. Substring (0,2);
string s2 = str. Substring (2,2);

int T1 = Convert.ToInt32 (s1,16);
int t2 = Convert.ToInt32 (s2,16);

Array[0] = (byte) t1;
ARRAY[1] = (byte) t2;

string s = System.Text.Encoding.Unicode.GetString (array);

Default mode reverse decoding for Chinese characters
Array[0] = (byte) 196;
ARRAY[1] = (byte) 207;
s = System.Text.Encoding.Default.GetString (array);

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.