有没有哪位高人知道如何将Byte数组转成String,及String转成Byte数组,请赐教
------解决思路----------------------
我的了解:byte是范围为0~255的整数,如果转换成string。那么就直接string(xx)就可以了。
至于数组的转换的思路,通过upperbound获取数组的上限,
然后用for..next循环赋值成string,或者byte。
------解决思路----------------------
string ls_buf
byte lbya_data[] = {178, 226, 202, 212}
ls_buf = String(Blob(lbya_data), EncodingANSI!)
messagebox('Ansi byte[] 转 string', ls_buf)
string ls_data = "测试"
byte lbya_buf[]
lbya_buf = GetByteArray(Blob(ls_data))
messagebox('string 转 Unicode byte[]', string(blob(lbya_buf)))
/*
// 按单字节字符集提取字符串的 ascii 码
string ls_data = "测试", ls_buf
blob{2} lbl_word
blob lbl_data
lbl_data = Blob(ls_data, EncodingANSI!)
SetByte(lbl_word, 1, Byte(BlobMid(lbl_data, 1, 1)))
ls_buf += String(Asc(String(lbl_word))) + ","
SetByte(lbl_word, 1, Byte(BlobMid(lbl_data, 2, 1)))
ls_buf += String(Asc(String(lbl_word))) + ","
SetByte(lbl_word, 1, Byte(BlobMid(lbl_data, 3, 1)))
ls_buf += String(Asc(String(lbl_word))) + ","
SetByte(lbl_word, 1, Byte(BlobMid(lbl_data, 4, 1)))
ls_buf += String(Asc(String(lbl_word)))
messagebox('“测试”的 Ansi 码', ls_buf)
*/
------解决思路----------------------
toString啊,Byte数组存的ASCII码吗?string(blob(byte[]))