Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenicy2utf8.c
Go to the documentation of this file.
00001 /* mpg123 note: This is BSD-licensed code that is no problem for mpg123 usage under LGPL. 00002 It's Free, understood? ;-) */ 00003 00004 /* Another note: This code is basically written by Thorsten Glaser, 00005 Thomas Orgis did just some rearrangements and comments. */ 00006 00007 /*- 00008 * Copyright (c) 2008 00009 * Thorsten Glaser <tg@mirbsd.org> 00010 * 00011 * Provided that these terms and disclaimer and all copyright notices 00012 * are retained or reproduced in an accompanying document, permission 00013 * is granted to deal in this work without restriction, including un- 00014 * limited rights to use, publicly perform, distribute, sell, modify, 00015 * merge, give away, or sublicence. 00016 * 00017 * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to 00018 * the utmost extent permitted by applicable law, neither express nor 00019 * implied; without malicious intent or gross negligence. In no event 00020 * may a licensor, author or contributor be held liable for indirect, 00021 * direct, other damage, loss, or other issues arising in any way out 00022 * of dealing in the work, even if advised of the possibility of such 00023 * damage or existence of a defect, except proven that it results out 00024 * of said person's immediate fault when using the work as intended. 00025 *- 00026 * Convert from ICY encoding (windows-1252 codepage) to UTF-8 00027 */ 00028 00029 /* Includes string and stdlib headers... */ 00030 #include "compat.h" 00031 00032 /* ThOr: too lazy for this type check; also we use char/short all around anyway. 00033 Of cource, it would be the proper way to use _these_ kind of types all around. */ 00034 #define uint8_t unsigned char 00035 #define uint16_t unsigned short 00036 00037 static const uint8_t cp1252_utf8[] = { 00038 /* 0x00 @ 0 */ 0x00, 00039 /* 0x01 @ 1 */ 0x01, 00040 /* 0x02 @ 2 */ 0x02, 00041 /* 0x03 @ 3 */ 0x03, 00042 /* 0x04 @ 4 */ 0x04, 00043 /* 0x05 @ 5 */ 0x05, 00044 /* 0x06 @ 6 */ 0x06, 00045 /* 0x07 @ 7 */ 0x07, 00046 /* 0x08 @ 8 */ 0x08, 00047 /* 0x09 @ 9 */ 0x09, 00048 /* 0x0A @ 10 */ 0x0A, 00049 /* 0x0B @ 11 */ 0x0B, 00050 /* 0x0C @ 12 */ 0x0C, 00051 /* 0x0D @ 13 */ 0x0D, 00052 /* 0x0E @ 14 */ 0x0E, 00053 /* 0x0F @ 15 */ 0x0F, 00054 /* 0x10 @ 16 */ 0x10, 00055 /* 0x11 @ 17 */ 0x11, 00056 /* 0x12 @ 18 */ 0x12, 00057 /* 0x13 @ 19 */ 0x13, 00058 /* 0x14 @ 20 */ 0x14, 00059 /* 0x15 @ 21 */ 0x15, 00060 /* 0x16 @ 22 */ 0x16, 00061 /* 0x17 @ 23 */ 0x17, 00062 /* 0x18 @ 24 */ 0x18, 00063 /* 0x19 @ 25 */ 0x19, 00064 /* 0x1A @ 26 */ 0x1A, 00065 /* 0x1B @ 27 */ 0x1B, 00066 /* 0x1C @ 28 */ 0x1C, 00067 /* 0x1D @ 29 */ 0x1D, 00068 /* 0x1E @ 30 */ 0x1E, 00069 /* 0x1F @ 31 */ 0x1F, 00070 /* 0x20 @ 32 */ 0x20, 00071 /* 0x21 @ 33 */ 0x21, 00072 /* 0x22 @ 34 */ 0x22, 00073 /* 0x23 @ 35 */ 0x23, 00074 /* 0x24 @ 36 */ 0x24, 00075 /* 0x25 @ 37 */ 0x25, 00076 /* 0x26 @ 38 */ 0x26, 00077 /* 0x27 @ 39 */ 0x27, 00078 /* 0x28 @ 40 */ 0x28, 00079 /* 0x29 @ 41 */ 0x29, 00080 /* 0x2A @ 42 */ 0x2A, 00081 /* 0x2B @ 43 */ 0x2B, 00082 /* 0x2C @ 44 */ 0x2C, 00083 /* 0x2D @ 45 */ 0x2D, 00084 /* 0x2E @ 46 */ 0x2E, 00085 /* 0x2F @ 47 */ 0x2F, 00086 /* 0x30 @ 48 */ 0x30, 00087 /* 0x31 @ 49 */ 0x31, 00088 /* 0x32 @ 50 */ 0x32, 00089 /* 0x33 @ 51 */ 0x33, 00090 /* 0x34 @ 52 */ 0x34, 00091 /* 0x35 @ 53 */ 0x35, 00092 /* 0x36 @ 54 */ 0x36, 00093 /* 0x37 @ 55 */ 0x37, 00094 /* 0x38 @ 56 */ 0x38, 00095 /* 0x39 @ 57 */ 0x39, 00096 /* 0x3A @ 58 */ 0x3A, 00097 /* 0x3B @ 59 */ 0x3B, 00098 /* 0x3C @ 60 */ 0x3C, 00099 /* 0x3D @ 61 */ 0x3D, 00100 /* 0x3E @ 62 */ 0x3E, 00101 /* 0x3F @ 63 */ 0x3F, 00102 /* 0x40 @ 64 */ 0x40, 00103 /* 0x41 @ 65 */ 0x41, 00104 /* 0x42 @ 66 */ 0x42, 00105 /* 0x43 @ 67 */ 0x43, 00106 /* 0x44 @ 68 */ 0x44, 00107 /* 0x45 @ 69 */ 0x45, 00108 /* 0x46 @ 70 */ 0x46, 00109 /* 0x47 @ 71 */ 0x47, 00110 /* 0x48 @ 72 */ 0x48, 00111 /* 0x49 @ 73 */ 0x49, 00112 /* 0x4A @ 74 */ 0x4A, 00113 /* 0x4B @ 75 */ 0x4B, 00114 /* 0x4C @ 76 */ 0x4C, 00115 /* 0x4D @ 77 */ 0x4D, 00116 /* 0x4E @ 78 */ 0x4E, 00117 /* 0x4F @ 79 */ 0x4F, 00118 /* 0x50 @ 80 */ 0x50, 00119 /* 0x51 @ 81 */ 0x51, 00120 /* 0x52 @ 82 */ 0x52, 00121 /* 0x53 @ 83 */ 0x53, 00122 /* 0x54 @ 84 */ 0x54, 00123 /* 0x55 @ 85 */ 0x55, 00124 /* 0x56 @ 86 */ 0x56, 00125 /* 0x57 @ 87 */ 0x57, 00126 /* 0x58 @ 88 */ 0x58, 00127 /* 0x59 @ 89 */ 0x59, 00128 /* 0x5A @ 90 */ 0x5A, 00129 /* 0x5B @ 91 */ 0x5B, 00130 /* 0x5C @ 92 */ 0x5C, 00131 /* 0x5D @ 93 */ 0x5D, 00132 /* 0x5E @ 94 */ 0x5E, 00133 /* 0x5F @ 95 */ 0x5F, 00134 /* 0x60 @ 96 */ 0x60, 00135 /* 0x61 @ 97 */ 0x61, 00136 /* 0x62 @ 98 */ 0x62, 00137 /* 0x63 @ 99 */ 0x63, 00138 /* 0x64 @ 100 */ 0x64, 00139 /* 0x65 @ 101 */ 0x65, 00140 /* 0x66 @ 102 */ 0x66, 00141 /* 0x67 @ 103 */ 0x67, 00142 /* 0x68 @ 104 */ 0x68, 00143 /* 0x69 @ 105 */ 0x69, 00144 /* 0x6A @ 106 */ 0x6A, 00145 /* 0x6B @ 107 */ 0x6B, 00146 /* 0x6C @ 108 */ 0x6C, 00147 /* 0x6D @ 109 */ 0x6D, 00148 /* 0x6E @ 110 */ 0x6E, 00149 /* 0x6F @ 111 */ 0x6F, 00150 /* 0x70 @ 112 */ 0x70, 00151 /* 0x71 @ 113 */ 0x71, 00152 /* 0x72 @ 114 */ 0x72, 00153 /* 0x73 @ 115 */ 0x73, 00154 /* 0x74 @ 116 */ 0x74, 00155 /* 0x75 @ 117 */ 0x75, 00156 /* 0x76 @ 118 */ 0x76, 00157 /* 0x77 @ 119 */ 0x77, 00158 /* 0x78 @ 120 */ 0x78, 00159 /* 0x79 @ 121 */ 0x79, 00160 /* 0x7A @ 122 */ 0x7A, 00161 /* 0x7B @ 123 */ 0x7B, 00162 /* 0x7C @ 124 */ 0x7C, 00163 /* 0x7D @ 125 */ 0x7D, 00164 /* 0x7E @ 126 */ 0x7E, 00165 /* 0x7F @ 127 */ 0x7F, 00166 /* 0x80 @ 128 */ 0xE2, 0x82, 0xAC, 00167 /* 0x81 @ 131 */ 0xEF, 0xBF, 0xBD, 00168 /* 0x82 @ 134 */ 0xE2, 0x80, 0x9A, 00169 /* 0x83 @ 137 */ 0xC6, 0x92, 00170 /* 0x84 @ 139 */ 0xE2, 0x80, 0x9E, 00171 /* 0x85 @ 142 */ 0xE2, 0x80, 0xA6, 00172 /* 0x86 @ 145 */ 0xE2, 0x80, 0xA0, 00173 /* 0x87 @ 148 */ 0xE2, 0x80, 0xA1, 00174 /* 0x88 @ 151 */ 0xCB, 0x86, 00175 /* 0x89 @ 153 */ 0xE2, 0x80, 0xB0, 00176 /* 0x8A @ 156 */ 0xC5, 0xA0, 00177 /* 0x8B @ 158 */ 0xE2, 0x80, 0xB9, 00178 /* 0x8C @ 161 */ 0xC5, 0x92, 00179 /* 0x8D @ 163 */ 0xEF, 0xBF, 0xBD, 00180 /* 0x8E @ 166 */ 0xC5, 0xBD, 00181 /* 0x8F @ 168 */ 0xEF, 0xBF, 0xBD, 00182 /* 0x90 @ 171 */ 0xEF, 0xBF, 0xBD, 00183 /* 0x91 @ 174 */ 0xE2, 0x80, 0x98, 00184 /* 0x92 @ 177 */ 0xE2, 0x80, 0x99, 00185 /* 0x93 @ 180 */ 0xE2, 0x80, 0x9C, 00186 /* 0x94 @ 183 */ 0xE2, 0x80, 0x9D, 00187 /* 0x95 @ 186 */ 0xE2, 0x80, 0xA2, 00188 /* 0x96 @ 189 */ 0xE2, 0x80, 0x93, 00189 /* 0x97 @ 192 */ 0xE2, 0x80, 0x94, 00190 /* 0x98 @ 195 */ 0xCB, 0x9C, 00191 /* 0x99 @ 197 */ 0xE2, 0x84, 0xA2, 00192 /* 0x9A @ 200 */ 0xC5, 0xA1, 00193 /* 0x9B @ 202 */ 0xE2, 0x80, 0xBA, 00194 /* 0x9C @ 205 */ 0xC5, 0x93, 00195 /* 0x9D @ 207 */ 0xEF, 0xBF, 0xBD, 00196 /* 0x9E @ 210 */ 0xC5, 0xBE, 00197 /* 0x9F @ 212 */ 0xC5, 0xB8, 00198 /* 0xA0 @ 214 */ 0xC2, 0xA0, 00199 /* 0xA1 @ 216 */ 0xC2, 0xA1, 00200 /* 0xA2 @ 218 */ 0xC2, 0xA2, 00201 /* 0xA3 @ 220 */ 0xC2, 0xA3, 00202 /* 0xA4 @ 222 */ 0xC2, 0xA4, 00203 /* 0xA5 @ 224 */ 0xC2, 0xA5, 00204 /* 0xA6 @ 226 */ 0xC2, 0xA6, 00205 /* 0xA7 @ 228 */ 0xC2, 0xA7, 00206 /* 0xA8 @ 230 */ 0xC2, 0xA8, 00207 /* 0xA9 @ 232 */ 0xC2, 0xA9, 00208 /* 0xAA @ 234 */ 0xC2, 0xAA, 00209 /* 0xAB @ 236 */ 0xC2, 0xAB, 00210 /* 0xAC @ 238 */ 0xC2, 0xAC, 00211 /* 0xAD @ 240 */ 0xC2, 0xAD, 00212 /* 0xAE @ 242 */ 0xC2, 0xAE, 00213 /* 0xAF @ 244 */ 0xC2, 0xAF, 00214 /* 0xB0 @ 246 */ 0xC2, 0xB0, 00215 /* 0xB1 @ 248 */ 0xC2, 0xB1, 00216 /* 0xB2 @ 250 */ 0xC2, 0xB2, 00217 /* 0xB3 @ 252 */ 0xC2, 0xB3, 00218 /* 0xB4 @ 254 */ 0xC2, 0xB4, 00219 /* 0xB5 @ 256 */ 0xC2, 0xB5, 00220 /* 0xB6 @ 258 */ 0xC2, 0xB6, 00221 /* 0xB7 @ 260 */ 0xC2, 0xB7, 00222 /* 0xB8 @ 262 */ 0xC2, 0xB8, 00223 /* 0xB9 @ 264 */ 0xC2, 0xB9, 00224 /* 0xBA @ 266 */ 0xC2, 0xBA, 00225 /* 0xBB @ 268 */ 0xC2, 0xBB, 00226 /* 0xBC @ 270 */ 0xC2, 0xBC, 00227 /* 0xBD @ 272 */ 0xC2, 0xBD, 00228 /* 0xBE @ 274 */ 0xC2, 0xBE, 00229 /* 0xBF @ 276 */ 0xC2, 0xBF, 00230 /* 0xC0 @ 278 */ 0xC3, 0x80, 00231 /* 0xC1 @ 280 */ 0xC3, 0x81, 00232 /* 0xC2 @ 282 */ 0xC3, 0x82, 00233 /* 0xC3 @ 284 */ 0xC3, 0x83, 00234 /* 0xC4 @ 286 */ 0xC3, 0x84, 00235 /* 0xC5 @ 288 */ 0xC3, 0x85, 00236 /* 0xC6 @ 290 */ 0xC3, 0x86, 00237 /* 0xC7 @ 292 */ 0xC3, 0x87, 00238 /* 0xC8 @ 294 */ 0xC3, 0x88, 00239 /* 0xC9 @ 296 */ 0xC3, 0x89, 00240 /* 0xCA @ 298 */ 0xC3, 0x8A, 00241 /* 0xCB @ 300 */ 0xC3, 0x8B, 00242 /* 0xCC @ 302 */ 0xC3, 0x8C, 00243 /* 0xCD @ 304 */ 0xC3, 0x8D, 00244 /* 0xCE @ 306 */ 0xC3, 0x8E, 00245 /* 0xCF @ 308 */ 0xC3, 0x8F, 00246 /* 0xD0 @ 310 */ 0xC3, 0x90, 00247 /* 0xD1 @ 312 */ 0xC3, 0x91, 00248 /* 0xD2 @ 314 */ 0xC3, 0x92, 00249 /* 0xD3 @ 316 */ 0xC3, 0x93, 00250 /* 0xD4 @ 318 */ 0xC3, 0x94, 00251 /* 0xD5 @ 320 */ 0xC3, 0x95, 00252 /* 0xD6 @ 322 */ 0xC3, 0x96, 00253 /* 0xD7 @ 324 */ 0xC3, 0x97, 00254 /* 0xD8 @ 326 */ 0xC3, 0x98, 00255 /* 0xD9 @ 328 */ 0xC3, 0x99, 00256 /* 0xDA @ 330 */ 0xC3, 0x9A, 00257 /* 0xDB @ 332 */ 0xC3, 0x9B, 00258 /* 0xDC @ 334 */ 0xC3, 0x9C, 00259 /* 0xDD @ 336 */ 0xC3, 0x9D, 00260 /* 0xDE @ 338 */ 0xC3, 0x9E, 00261 /* 0xDF @ 340 */ 0xC3, 0x9F, 00262 /* 0xE0 @ 342 */ 0xC3, 0xA0, 00263 /* 0xE1 @ 344 */ 0xC3, 0xA1, 00264 /* 0xE2 @ 346 */ 0xC3, 0xA2, 00265 /* 0xE3 @ 348 */ 0xC3, 0xA3, 00266 /* 0xE4 @ 350 */ 0xC3, 0xA4, 00267 /* 0xE5 @ 352 */ 0xC3, 0xA5, 00268 /* 0xE6 @ 354 */ 0xC3, 0xA6, 00269 /* 0xE7 @ 356 */ 0xC3, 0xA7, 00270 /* 0xE8 @ 358 */ 0xC3, 0xA8, 00271 /* 0xE9 @ 360 */ 0xC3, 0xA9, 00272 /* 0xEA @ 362 */ 0xC3, 0xAA, 00273 /* 0xEB @ 364 */ 0xC3, 0xAB, 00274 /* 0xEC @ 366 */ 0xC3, 0xAC, 00275 /* 0xED @ 368 */ 0xC3, 0xAD, 00276 /* 0xEE @ 370 */ 0xC3, 0xAE, 00277 /* 0xEF @ 372 */ 0xC3, 0xAF, 00278 /* 0xF0 @ 374 */ 0xC3, 0xB0, 00279 /* 0xF1 @ 376 */ 0xC3, 0xB1, 00280 /* 0xF2 @ 378 */ 0xC3, 0xB2, 00281 /* 0xF3 @ 380 */ 0xC3, 0xB3, 00282 /* 0xF4 @ 382 */ 0xC3, 0xB4, 00283 /* 0xF5 @ 384 */ 0xC3, 0xB5, 00284 /* 0xF6 @ 386 */ 0xC3, 0xB6, 00285 /* 0xF7 @ 388 */ 0xC3, 0xB7, 00286 /* 0xF8 @ 390 */ 0xC3, 0xB8, 00287 /* 0xF9 @ 392 */ 0xC3, 0xB9, 00288 /* 0xFA @ 394 */ 0xC3, 0xBA, 00289 /* 0xFB @ 396 */ 0xC3, 0xBB, 00290 /* 0xFC @ 398 */ 0xC3, 0xBC, 00291 /* 0xFD @ 400 */ 0xC3, 0xBD, 00292 /* 0xFE @ 402 */ 0xC3, 0xBE, 00293 /* 0xFF @ 404 */ 0xC3, 0xBF, 00294 }; 00295 00296 static const uint16_t tblofs[257] = { 00297 /* 0x00 */ 0, 1, 2, 3, 4, 5, 6, 7, 00298 /* 0x08 */ 8, 9, 10, 11, 12, 13, 14, 15, 00299 /* 0x10 */ 16, 17, 18, 19, 20, 21, 22, 23, 00300 /* 0x18 */ 24, 25, 26, 27, 28, 29, 30, 31, 00301 /* 0x20 */ 32, 33, 34, 35, 36, 37, 38, 39, 00302 /* 0x28 */ 40, 41, 42, 43, 44, 45, 46, 47, 00303 /* 0x30 */ 48, 49, 50, 51, 52, 53, 54, 55, 00304 /* 0x38 */ 56, 57, 58, 59, 60, 61, 62, 63, 00305 /* 0x40 */ 64, 65, 66, 67, 68, 69, 70, 71, 00306 /* 0x48 */ 72, 73, 74, 75, 76, 77, 78, 79, 00307 /* 0x50 */ 80, 81, 82, 83, 84, 85, 86, 87, 00308 /* 0x58 */ 88, 89, 90, 91, 92, 93, 94, 95, 00309 /* 0x60 */ 96, 97, 98, 99, 100, 101, 102, 103, 00310 /* 0x68 */ 104, 105, 106, 107, 108, 109, 110, 111, 00311 /* 0x70 */ 112, 113, 114, 115, 116, 117, 118, 119, 00312 /* 0x78 */ 120, 121, 122, 123, 124, 125, 126, 127, 00313 /* 0x80 */ 128, 131, 134, 137, 139, 142, 145, 148, 00314 /* 0x88 */ 151, 153, 156, 158, 161, 163, 166, 168, 00315 /* 0x90 */ 171, 174, 177, 180, 183, 186, 189, 192, 00316 /* 0x98 */ 195, 197, 200, 202, 205, 207, 210, 212, 00317 /* 0xA0 */ 214, 216, 218, 220, 222, 224, 226, 228, 00318 /* 0xA8 */ 230, 232, 234, 236, 238, 240, 242, 244, 00319 /* 0xB0 */ 246, 248, 250, 252, 254, 256, 258, 260, 00320 /* 0xB8 */ 262, 264, 266, 268, 270, 272, 274, 276, 00321 /* 0xC0 */ 278, 280, 282, 284, 286, 288, 290, 292, 00322 /* 0xC8 */ 294, 296, 298, 300, 302, 304, 306, 308, 00323 /* 0xD0 */ 310, 312, 314, 316, 318, 320, 322, 324, 00324 /* 0xD8 */ 326, 328, 330, 332, 334, 336, 338, 340, 00325 /* 0xE0 */ 342, 344, 346, 348, 350, 352, 354, 356, 00326 /* 0xE8 */ 358, 360, 362, 364, 366, 368, 370, 372, 00327 /* 0xF0 */ 374, 376, 378, 380, 382, 384, 386, 388, 00328 /* 0xF8 */ 390, 392, 394, 396, 398, 400, 402, 404, 00329 /* sizeof (cp1252_utf8) */ 406 00330 }; 00331 00332 /* Check if a string qualifies as UTF-8. */ 00333 static int 00334 is_utf8(const char* src) 00335 { 00336 uint8_t ch; 00337 size_t i; 00338 const uint8_t* s = (const uint8_t*) src; 00339 00340 /* We make a loop over every character, until we find a null one. 00341 Remember: The string is supposed to end with a NUL, so ahead checks are safe. */ 00342 while ((ch = *s++)) { 00343 /* Ye olde 7bit ASCII chars 'rr fine for anything */ 00344 if(ch < 0x80) continue; 00345 00346 /* Now, we watch out for non-UTF conform sequences. */ 00347 else if ((ch < 0xC2) || (ch > 0xFD)) 00348 return 0; 00349 /* check for some misformed sequences */ 00350 if (((ch == 0xC2) && (s[0] < 0xA0)) || 00351 ((ch == 0xEF) && (s[0] == 0xBF) && (s[1] > 0xBD))) 00352 /* XXX add more for outside the BMP */ 00353 return 0; 00354 00355 /* Check the continuation bytes. */ 00356 if (ch < 0xE0) i = 1; 00357 else if (ch < 0xF0) i = 2; 00358 else if (ch < 0xF8) i = 3; 00359 else if (ch < 0xFC) i = 4; 00360 else 00361 i = 5; 00362 00363 while (i--) 00364 if ((*s++ & 0xC0) != 0x80) 00365 return 0; 00366 } 00367 00368 /* If no check failed, the string indeed looks like valid UTF-8. */ 00369 return 1; 00370 } 00371 00372 /* The main conversion routine. 00373 ICY in CP-1252 (or UTF-8 alreay) to UTF-8 encoded string. 00374 If force is applied, it will always encode to UTF-8, without checking. */ 00375 char * 00376 icy2utf8(const char *src, int force) 00377 { 00378 const uint8_t *s = (const uint8_t *)src; 00379 size_t srclen, dstlen, i, k; 00380 uint8_t ch, *d; 00381 char *dst; 00382 00383 /* Some funny streams from Apple/iTunes give ICY info in UTF-8 already. 00384 So, be prepared and don't try to re-encode such. Unless forced. */ 00385 if(!force && is_utf8(src)) return (strdup(src)); 00386 00387 srclen = strlen(src) + 1; 00388 /* allocate conservatively */ 00389 if ((d = malloc(srclen * 3)) == NULL) 00390 return (NULL); 00391 00392 i = 0; 00393 dstlen = 0; 00394 while (i < srclen) { 00395 ch = s[i++]; 00396 k = tblofs[ch]; 00397 while (k < tblofs[ch + 1]) 00398 d[dstlen++] = cp1252_utf8[k++]; 00399 } 00400 00401 /* dstlen includes trailing NUL since srclen also does */ 00402 if ((dst = realloc(d, dstlen)) == NULL) { 00403 free(d); 00404 return (NULL); 00405 } 00406 return (dst); 00407 } 00408 00409 /* This stuff is for testing only. */ 00410 #ifdef TEST 00411 static const char intext[] = "\225 Gr\374\337e kosten 0,55 \200\205"; 00412 00413 #include <stdio.h> 00414 00415 int 00416 main(void) 00417 { 00418 char *t, *t2; 00419 00420 if ((t = icy2utf8(intext, 0)) == NULL) { 00421 fprintf(stderr, "out of memory\n"); 00422 return (1); 00423 } 00424 00425 /* make sure it won't be converted twice */ 00426 if ((t2 = icy2utf8(t), 0) == NULL) { 00427 fprintf(stderr, "out of memory\n"); 00428 return (1); 00429 } 00430 00431 printf("Result is:\t\343\200\214%s\343\200\215\n" 00432 "\t\t\343\200\214%s\343\200\215\n", t, t2); 00433 00434 free(t); 00435 free(t2); 00436 return (0); 00437 } 00438 #endif Generated on Fri May 25 2012 04:32:36 for ReactOS by
1.7.6.1
|