87,960
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
new String(new byte[]{-76,-42})
public static String decode(String hexStr){
String[] ah=hexStr.split(",");
int len=ah.length;
byte[] bytes=new byte[len];
for(int i=0,t;i<len;i++){
t=Integer.parseInt(ah[i],16);
if(t<128){
bytes[i]=(byte)t;
}else{
t-=256;
bytes[i+1]=(byte)t;
t=Integer.parseInt(ah[i+1],16);
bytes[i]=(byte)(t-256);
i++;
}
}
return new String(bytes);
}
System.out.println(decode("a4,b9,20,20,20,20,f2,d0,20,20,20,20,da,c4,20,20,20,20,dd,c8"));
alert(String.fromCharCode(31895))
function decode(hexStr){
var ah=hexStr.split(',');
var len=ah.length;
var bytes=[];
for(var i=0,t;i<len;i++){
t=parseInt(ah[i],16);
if(t<128){
bytes[i]=t;
}else{
t-=256;
bytes[i+1]=t;
t=parseInt(ah[i+1],16);
bytes[i]=(t-256);
i++;
}
}
var s=//怎么操作bytes, 参数hexStr=‘a4,b9,20,20,20,20,f2,d0,20,20,20,20,da,c4,20,20,20,20,dd,c8’
//想return s='工 序 内 容' 这段内容
return s;
}
function decode(hexStr){
var ah=hexStr.split(',');
var len=ah.length;
var bytes=[];
for(var i=0,t;i<len;i++){
t=parseInt(ah[i],16);
if(t<128){
bytes[i]=t;
}else{
t-=256;
bytes[i+1]=t;
t=parseInt(ah[i+1],16);
bytes[i]=(t-256);
i++;
}
}
//var s=bytes.join(','); 这里是测试代码
//var s=怎么操作bytes得到粗这个字 hexStr是 a4,b9,20,20,20,20,f2,d0,20,20,20,20,da,c4,20,20,20,20,dd,c8
//想得到 s="工 序 内 容" 这段内容
return s;
}
不局限于上面的函数 用其他js方法得出就行
也就是一个function 我输入'a4,b9,20,20,20,20,f2,d0,20,20,20,20,da,c4,20,20,20,20,dd,c8'
return '工 序 内 容';
alert(String.fromCharCode(31895))//粗
alert('粗'.charCodeAt(0))//31895