2011年9月28日
摘要: public int GetBytesOfString(string str) {//获取字符串的字节数 byte[] bytes = Encoding.Unicode.GetBytes(str); int n = 0; for (int i = 0; i < bytes.GetLength(0); i++) { // 偶数位置,如0、2、4等,为UCS2编码中两个字节的第一个字节 if (i % 2 == 0) { n++; // 在UCS2第一个字节时n加1 } else { // 当UCS2编码的第二个字节大于0时,该UCS2字符为汉字,一个汉字算两个字节 if (bytes[i] 阅读全文
posted @ 2011-09-28 12:49 鞋子里的精灵 阅读(607) 评论(0) 推荐(0)