Marook-Online
* 06.Feb.2012, 15:38 UTC+1
Welcome, Guest. Please login or register.
Username:
Password:

News: Back again Wink
Main Menu
  Navigation
   Downloads
     Tools
     Music Discs
     SMF Mods
     Trainer & Patches
     EgoShare Uploader
   Guestbook
   NoPaste
   User Map
   Gallery
  
   Malware Scan
   Hacker Blacklist
   Find Abusemail
Top Downloads
Support Me !
Help me by donating a small amount!



Advanced search

Google


Pages: [1]   Go Down
0 Members and 1 Guest are viewing this topic. Topic Tools  
Read
23-May-2008 15:11
Marook
Administrator
*****
Offline Offline

Joined: 01-Jan-2005
Posts: 224


Sometimes you need to decode some utf8 strings is JS, so just use this piece of code Wink

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

Pages: [1]   Go Up
Jump to:  

Theme by webtechnica.net

MHD v2.1 © 2oo8 by Marook
32116 hacking attempts defended!