Some string operations in C #

xiaoxiao2021-03-06  67

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

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

// unicode decoding method in the Chinese character 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 the string length s = "IAM square gun"; int Len = s.length; // will output as 6 byte [] SARR = system.text.Encoding.default.getbytes (s); len = SARR. 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 ("square gun ");

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

New Post(0)