home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / recode.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  3.4 KB  |  82 lines

  1. Recode 
  2.  
  3. Recode Strings from IBMPC to Latin1. Useful with old DBase-Databases. Expandable for other convertions
  4.  
  5.  
  6. <?php 
  7.  
  8. /* Written by Dirk Ostendorf (ostendorf@unity.de) 
  9.  
  10. **** 
  11. This class is provided with no guarantees that it will either 
  12. work properly or not trash your machine. So don't blame me if 
  13. it does. It works great for me though, and you can do whatever 
  14. you want to it in the name of free software. 
  15. **** 
  16.  
  17. I wanted to have a sort of 'recode' to convert ibmpc-strings from 
  18. a dbase-database to the latin1-charset to show them on a Windows PC 
  19. and the possibility to expand this class to do other recodings. 
  20.  
  21. FUNCTIONS: 
  22. ibmpc_to_latin1($stringToConvert)    //recodes from ibmpc to latin1 
  23.  
  24. */ 
  25.    
  26. class convert 
  27.     var    $onechar= ""; 
  28.     var    $ascii=0; 
  29.     var    $convertedString= ""; 
  30.  
  31.      // Conversion table from `ibmpc' charset to `latin1' charset. 
  32.      // Generated mechanically by GNU recode 3.4. 
  33.  
  34.     var $ibmpcToLatin1 = array( 
  35.       0,   1,   2,   3,   4,   5,   6,   7,     /*   0 -   7 */ 
  36.       8,   9,  10,  11,  12,  13,  14,  15,     /*   8 -  15 */ 
  37.      16,  17,  18,  19, 182, 167,  22,  23,     /*  16 -  23 */ 
  38.      24,  25,  26,  27,  28,  29,  30,  31,     /*  24 -  31 */ 
  39.      32,  33,  34,  35,  36,  37,  38,  39,     /*  32 -  39 */ 
  40.      40,  41,  42,  43,  44,  45,  46,  47,     /*  40 -  47 */ 
  41.      48,  49,  50,  51,  52,  53,  54,  55,     /*  48 -  55 */ 
  42.      56,  57,  58,  59,  60,  61,  62,  63,     /*  56 -  63 */ 
  43.      64,  65,  66,  67,  68,  69,  70,  71,     /*  64 -  71 */ 
  44.      72,  73,  74,  75,  76,  77,  78,  79,     /*  72 -  79 */ 
  45.      80,  81,  82,  83,  84,  85,  86,  87,     /*  80 -  87 */ 
  46.      88,  89,  90,  91,  92,  93,  94,  95,     /*  88 -  95 */ 
  47.      96,  97,  98,  99, 100, 101, 102, 103,     /*  96 - 103 */ 
  48.     104, 105, 106, 107, 108, 109, 110, 111,     /* 104 - 111 */ 
  49.     112, 113, 114, 115, 116, 117, 118, 119,     /* 112 - 119 */ 
  50.     120, 121, 122, 123, 124, 125, 126, 127,     /* 120 - 127 */ 
  51.     199, 252, 233, 226, 228, 224, 229, 231,     /* 128 - 135 */ 
  52.     234, 235, 232, 239, 238, 236, 196, 197,     /* 136 - 143 */ 
  53.     201, 230, 198, 244, 246, 242, 251, 249,     /* 144 - 151 */ 
  54.     255, 214, 220, 162, 163, 165, 158, 159,     /* 152 - 159 */ 
  55.     225, 237, 243, 250, 241, 209, 170, 186,     /* 160 - 167 */ 
  56.     191, 169, 172, 189, 188, 161, 171, 187,     /* 168 - 175 */ 
  57.     248, 164, 253, 179, 180, 145,  20, 156,     /* 176 - 183 */ 
  58.     184, 185,  21, 175, 166, 174, 190, 168,     /* 184 - 191 */ 
  59.     192, 193, 194, 195, 142, 143, 146, 128,     /* 192 - 199 */ 
  60.     200, 144, 202, 203, 204, 205, 206, 207,     /* 200 - 207 */ 
  61.     208, 157, 210, 211, 212, 213, 153, 215,     /* 208 - 215 */ 
  62.     216, 217, 218, 219, 154, 221, 222, 152,     /* 216 - 223 */ 
  63.     133, 223, 131, 227, 132, 134, 181, 135,     /* 224 - 231 */ 
  64.     138, 130, 136, 137, 141, 173, 140, 139,     /* 232 - 239 */ 
  65.     240, 177, 149, 155, 147, 245, 247, 148,     /* 240 - 247 */ 
  66.     176, 151, 183, 150, 129, 178, 254, 160     /* 248 - 255 */ 
  67.     ); 
  68.  
  69.      
  70.     function ibmpc_to_latin1($stringToConvert){ 
  71.         for($i=0; $i<strlen($stringToConvert); $i++){ 
  72.             $this->onechar    = substr($stringToConvert,$i,1); 
  73.             $this->ascii      = ord($this->onechar); 
  74.             $convertedString .= chr($this->ibmpcToLatin1[$this->ascii]); 
  75.         } 
  76.         return ($convertedString); 
  77.     } 
  78. ?> 
  79.  
  80.