javaScript转码

//convert   utf-8   to   big5   or   gb2312

//转码(解决jsf中js alert中文乱码问题)
function   Unicode2Str(str){ 
	var   re=/&#[\da-fA-F]{1,5};/ig; 
	var   arr=str.match(re); 
	if(arr==null)return( " "); 
	var   size=arr.length; 
	var   arr2=new   Array(size); 
	for(var   i=0;i <arr.length;i++){ 
		arr2[i]=String.fromCharCode(arr[i].replace(/[&#;]/g, " ")); 
	} 
	for(var   i=0;i <arr.length;i++){ 
		str=str.replace(arr[i],arr2[i]); 
	} 
	//return(arr.toString().replace(/,/g, " ")) 
	return   str; 
}

 

你可能感兴趣的:(JavaScript,JSF,F#,Flash)