1 function utf8_decode(str_data){
2 var tmp_arr = [],i = 0,ac = 0,c1 = 0,c2 = 0,c3 = 0;str_data += '';
3 while (i < str_data.length) {
4 c1 = str_data.charCodeAt(i);
5 if (c1 < 128) {
6 tmp_arr[ac++] = String.fromCharCode(c1);
7 i++;
8 } else if (c1 > 191 && c1 < 224) {
9 c2 = str_data.charCodeAt(i + 1);
10 tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
11 i += 2;
12 } else {
13 c2 = str_data.charCodeAt(i + 1);
14 c3 = str_data.charCodeAt(i + 2);
15 tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
16 i += 3;
17 }
18 }
19 return tmp_arr.join('');
20 }