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