【php常用字符串函数】asp.net常用字符串处理函数

更新时间:2016-11-16    来源:php函数    手机版     字体:

【www.bbyears.com--php函数】

string   s= "$2.00 ";
s.replace( "$ ", "   ");
s.trim();

system.text.encoding.default.getbytecount(fox);获得字符串长度,一个汉字等于俩字符

//获得汉字的区位码
byte[] array = new byte[2];
array = system.text.encoding.default.getbytes("啊");

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

//unicode解码方式下的汉字码
array = system.text.encoding.unicode.getbytes("啊");
i1 = (short)(array[0] - "");
i2 = (short)(array[1] - "");

//unicode反解码为汉字
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方式反解码为汉字
array[0] = (byte)196;
array[1] = (byte)207;
s = system.text.encoding.default.getstring(array);


string fox;
fox.tolower()转化成小写字母
fox.toupper()转化成大写字母
fox.trim()删除前后空格
fox.trim(trimchars)删除其它字符
fox.trimstart()删除前空格
fox.trimend()删除后空格
fox.padleft(10)增加左边空格,使字串达到某长度。
fox.padright(10)增加右边空格,使字串达到某长度。
fox.padx(10,"-")增加其它字符,使字串达到某长度。x指:left/right
fox.split(" ")将字串分解成数组

本文来源:http://www.bbyears.com/jiaocheng/28320.html

猜你感兴趣