Some string operations in C #

xiaoxiao2021-03-06  40

// Get the zone code of Chinese characters Byte [] array = new byte [2]; array = system.text.Encoding.default.getbytes ("ah");

INT I1 = (short) (Array [0] - '' / 0 '); int I2 = (short) (Array [1] -' '/ 0');

// unicode decoding mode The Chinese characters array = system.text.Encoding.unicode.getbytes ("ah"); I1 = (short) (Array [0] - '' / 0 '); i2 = (Short) (Array [1] - '' / 0 '');

// unicode antique code is 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.uitode.getstring (array);

// Default method is a Chinese character array [0] = (byte) 196; array [1] = (byte) 207; s = system.text.encoding.default.getstring (array);

// Take a string length s = "woshi blue"; int Len = s.Length; // Will Output as 6 byte [] SARR = system.text.encoding.default.getbytes (s); len = sar.length ; // Will Output AS 3 3 * 2 = 9

// String plus system.text.StringBuilder SB = new system.text.StringBuilder (""); sb.append ("i"); sb.append ("am"); ​​sb.append ("Blue" );

/

supplement:

String -> Byte Array

Byte [] data = system.text.Encoding.ascii.getbytes (string);

String -> Byte

Byte Data = Convert.TobyTe (String);

Byte [] -> String

String string = encoding.ascii.getstring (bytes, 0, nbytessize);

转载请注明原文地址:https://www.9cbs.com/read-73012.html

New Post(0)