|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 /* "$Id: $" 00002 * 00003 * Author: Jean-Marc Lienher ( http://oksid.ch ) 00004 * Copyright 2000-2003 by O'ksi'D. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00019 * USA. 00020 * 00021 * Please report all bugs and problems on the following page: 00022 * 00023 * http://www.fltk.org/str.php 00024 */ 00025 00026 #include <stdlib.h> 00027 #include <string.h> 00028 00029 #define RET_ILSEQ -1 00030 #define RET_TOOFEW(x) (-10 - x) 00031 #define RET_TOOSMALL -2 00032 #define conv_t void* 00033 #define ucs4_t unsigned int 00034 typedef struct { 00035 unsigned short indx; 00036 unsigned short used; 00037 } Summary16; 00038 00039 #define NEED_TOMB // indicates what part of these include files is needed here (avoid compilation warnings) 00040 #include "lcUniConv/cp936ext.h" 00041 #include "lcUniConv/big5.h" 00042 #include "lcUniConv/gb2312.h" 00043 #include "lcUniConv/iso8859_10.h" 00044 #include "lcUniConv/iso8859_11.h" 00045 #include "lcUniConv/iso8859_13.h" 00046 #include "lcUniConv/iso8859_14.h" 00047 #include "lcUniConv/iso8859_15.h" 00048 #include "lcUniConv/iso8859_2.h" 00049 #include "lcUniConv/iso8859_3.h" 00050 #include "lcUniConv/iso8859_4.h" 00051 #include "lcUniConv/iso8859_5.h" 00052 #include "lcUniConv/iso8859_6.h" 00053 #include "lcUniConv/iso8859_7.h" 00054 #include "lcUniConv/iso8859_8.h" 00055 #include "lcUniConv/iso8859_9.h" 00056 #include "lcUniConv/jisx0201.h" 00057 #include "lcUniConv/jisx0208.h" 00058 #include "lcUniConv/jisx0212.h" 00059 #include "lcUniConv/koi8_r.h" 00060 #include "lcUniConv/koi8_u.h" 00061 #include "lcUniConv/ksc5601.h" 00062 #include "lcUniConv/cp1251.h" 00063 #include "headers/symbol_.h" 00064 #include "headers/dingbats_.h" 00065 00066 /*************** conv_gen.c ************/ 00067 00068 /*const*/ 00069 int ucs2fontmap(char *s, unsigned int ucs, int enc) { 00070 switch(enc) { 00071 case 0: /* iso10646-1 */ 00072 s[0] = (char) ((ucs & 0xFF00) >> 8); 00073 s[1] = (char) (ucs & 0xFF); 00074 return 0; 00075 break; 00076 case 1: /* iso8859-1 */ 00077 if (ucs <= 0x00FF) { 00078 if (ucs >= 0x0001) { 00079 s[0] = 0; 00080 s[1] = (char) (ucs & 0xFF); 00081 return 1; 00082 } 00083 } 00084 break; 00085 case 2: /* iso8859-2 */ 00086 if (ucs <= 0x00a0) { 00087 s[0] = 0; 00088 s[1] = (char) ucs; 00089 return 2; 00090 } else if (ucs < 0x0180) { 00091 if (ucs >= 0x00a0) { 00092 s[0] = 0; 00093 s[1] = (char) iso8859_2_page00[ucs-0x00a0]; 00094 if (s[1]) return 2; 00095 } 00096 } else if (ucs < 0x02e0) { 00097 if (ucs >= 0x02c0) { 00098 s[0] = 0; 00099 s[1] = (char) iso8859_2_page02[ucs-0x02c0]; 00100 if (s[1]) return 2; 00101 } 00102 } 00103 break; 00104 case 3: /* iso8859-3 */ 00105 if (iso8859_3_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00106 return 3; 00107 } 00108 break; 00109 case 4: /* iso8859-4 */ 00110 if (iso8859_4_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00111 return 4; 00112 } 00113 break; 00114 case 5: /* iso8859-5 */ 00115 if (iso8859_5_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00116 return 5; 00117 } 00118 break; 00119 case 6: /* iso8859-6 */ 00120 if (iso8859_6_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00121 return 6; 00122 } 00123 break; 00124 case 7: /* iso8859-7 */ 00125 if (iso8859_7_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00126 return 7; 00127 } 00128 break; 00129 case 8: /* iso8859-8 */ 00130 if (iso8859_8_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00131 return 8; 00132 } 00133 break; 00134 case 9: /* iso8859-9 */ 00135 if (iso8859_9_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00136 return 9; 00137 } 00138 break; 00139 case 10: /* iso8859-10 */ 00140 if (iso8859_10_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00141 return 10; 00142 } 00143 break; 00144 case 25: /* iso8859-11 */ 00145 if (iso8859_11_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00146 return 25; 00147 } 00148 break; 00149 case 11: /* iso8859-13 */ 00150 if (iso8859_13_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00151 return 11; 00152 } 00153 break; 00154 case 12: /* iso8859-14 */ 00155 if (iso8859_14_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00156 return 12; 00157 } 00158 break; 00159 case 13: /* iso8859-15 */ 00160 if (iso8859_15_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00161 return 13; 00162 } 00163 break; 00164 case 14: /* koi8-r */ 00165 if (koi8_r_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00166 return 14; 00167 } 00168 break; 00169 case 15: /* big5 */ 00170 if (big5_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00171 return 15; 00172 } 00173 break; 00174 case 16: /* ksc5601.1987-0 */ 00175 if (ksc5601_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00176 return 16; 00177 } 00178 break; 00179 case 17: /* gb2312.1980-0 */ 00180 if (gb2312_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00181 return 17; 00182 } 00183 break; 00184 case 18: /* jisx0201.1976-0 */ 00185 if (jisx0201_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00186 return 18; 00187 } 00188 break; 00189 case 19: /* jisx0208.1983-0 */ 00190 if (jisx0208_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00191 return 19; 00192 } 00193 break; 00194 case 20: /* jisx0212.1990-0 */ 00195 if (jisx0212_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00196 return 20; 00197 } 00198 break; 00199 case 21: /* symbol */ 00200 if (ucs <= 0x00F7) { 00201 if (ucs >= 0x0020) { 00202 s[0] = 0; 00203 s[1] = unicode_to_symbol_1b_0020[ucs - 0x0020]; 00204 if (s[1]) return 21; 00205 } 00206 } else if (ucs <= 0x0192) { 00207 if (ucs >= 0x0192) { 00208 s[0] = 0; 00209 s[1] = unicode_to_symbol_1b_0192[ucs - 0x0192]; 00210 if (s[1]) return 21; 00211 } 00212 } else if (ucs <= 0x03D6) { 00213 if (ucs >= 0x0391) { 00214 s[0] = 0; 00215 s[1] = unicode_to_symbol_1b_0391[ucs - 0x0391]; 00216 if (s[1]) return 21; 00217 } 00218 } else if (ucs <= 0x232A) { 00219 if (ucs >= 0x2022) { 00220 s[0] = 0; 00221 s[1] = unicode_to_symbol_1b_2022[ucs - 0x2022]; 00222 if (s[1]) return 21; 00223 } 00224 } else if (ucs <= 0x25CA) { 00225 if (ucs >= 0x25CA) { 00226 s[0] = 0; 00227 s[1] = unicode_to_symbol_1b_25CA[ucs - 0x25CA]; 00228 if (s[1]) return 21; 00229 } 00230 } else if (ucs <= 0x2666) { 00231 if (ucs >= 0x2660) { 00232 s[0] = 0; 00233 s[1] = unicode_to_symbol_1b_2660[ucs - 0x2660]; 00234 if (s[1]) return 21; 00235 } 00236 } else if (ucs <= 0xF6DB) { 00237 if (ucs >= 0xF6D9) { 00238 s[0] = 0; 00239 s[1] = unicode_to_symbol_1b_F6D9[ucs - 0xF6D9]; 00240 if (s[1]) return 21; 00241 } 00242 } else if (ucs <= 0xF8FE) { 00243 if (ucs >= 0xF8E5) { 00244 s[0] = 0; 00245 s[1] = unicode_to_symbol_1b_F8E5[ucs - 0xF8E5]; 00246 if (s[1]) return 21; 00247 } 00248 } 00249 break; 00250 case 22: /* dingbats */ 00251 if (ucs <= 0x00A0) { 00252 if (ucs >= 0x0020) { 00253 s[0] = 0; 00254 s[1] = unicode_to_dingbats_1b_0020[ucs - 0x0020]; 00255 if (s[1]) return 22; 00256 } 00257 } else if (ucs <= 0x2195) { 00258 if (ucs >= 0x2192) { 00259 s[0] = 0; 00260 s[1] = unicode_to_dingbats_1b_2192[ucs - 0x2192]; 00261 if (s[1]) return 22; 00262 } 00263 } else if (ucs <= 0x2469) { 00264 if (ucs >= 0x2460) { 00265 s[0] = 0; 00266 s[1] = unicode_to_dingbats_1b_2460[ucs - 0x2460]; 00267 if (s[1]) return 22; 00268 } 00269 } else if (ucs <= 0x2666) { 00270 if (ucs >= 0x25A0) { 00271 s[0] = 0; 00272 s[1] = unicode_to_dingbats_1b_25A0[ucs - 0x25A0]; 00273 if (s[1]) return 22; 00274 } 00275 } else if (ucs <= 0x27BE) { 00276 if (ucs >= 0x2701) { 00277 s[0] = 0; 00278 s[1] = unicode_to_dingbats_1b_2701[ucs - 0x2701]; 00279 if (s[1]) return 22; 00280 } 00281 } else if (ucs <= 0xF8E4) { 00282 if (ucs >= 0xF8D7) { 00283 s[0] = 0; 00284 s[1] = unicode_to_dingbats_1b_F8D7[ucs - 0xF8D7]; 00285 if (s[1]) return 22; 00286 } 00287 } 00288 break; 00289 case 23: /* koi8-u */ 00290 if (koi8_u_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00291 return 23; 00292 } 00293 break; 00294 case 24: /* microsoft-cp1251 */ 00295 if (cp1251_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00296 return 24; 00297 } 00298 break; 00299 case 26: /* gbk/cp936ext */ 00300 if (cp936ext_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) { 00301 return 26; 00302 } 00303 break; 00304 default: 00305 break; 00306 }; 00307 return -1; 00308 }; 00309 00310 /*const*/ 00311 int encoding_number(const char *enc) { 00312 if (!enc || !strncmp(enc, "iso10646-1", 10)) { 00313 return 0; 00314 } else if (!strcmp(enc, "iso8859-1")) { 00315 return 1; 00316 } else if (!strcmp(enc, "iso8859-2")) { 00317 return 2; 00318 } else if (!strcmp(enc, "iso8859-3")) { 00319 return 3; 00320 } else if (!strcmp(enc, "iso8859-4")) { 00321 return 4; 00322 } else if (!strcmp(enc, "iso8859-5")) { 00323 return 5; 00324 } else if (!strcmp(enc, "iso8859-6")) { 00325 return 6; 00326 } else if (!strcmp(enc, "iso8859-7")) { 00327 return 7; 00328 } else if (!strcmp(enc, "iso8859-8")) { 00329 return 8; 00330 } else if (!strcmp(enc, "iso8859-9")) { 00331 return 9; 00332 } else if (!strcmp(enc, "iso8859-10")) { 00333 return 10; 00334 } else if (!strcmp(enc, "iso8859-13")) { 00335 return 11; 00336 } else if (!strcmp(enc, "iso8859-14")) { 00337 return 12; 00338 } else if (!strcmp(enc, "iso8859-15")) { 00339 return 13; 00340 } else if (!strcmp(enc, "koi8-r")) { 00341 return 14; 00342 } else if (!strcmp(enc, "big5-0") || !strcmp(enc, "big5.eten-0") || 00343 !strcmp(enc, "big5p-0")) 00344 { 00345 return 15; 00346 } else if (!strcmp(enc, "ksc5601.1987-0")) { 00347 return 16; 00348 } else if (!strcmp(enc, "gb2312.1980-0") || !strcmp(enc, "gb2312.80-0") || 00349 !strcmp(enc, "gb2312.80&gb8565.88") || !strcmp(enc, "gb2312.80-0")) 00350 { 00351 return 17; 00352 } else if (!strcmp(enc, "jisx0201.1976-0")) { 00353 return 18; 00354 } else if (!strcmp(enc, "jisx0208.1983-0") || !strcmp(enc, "jisx0208.1990-0") 00355 || !strcmp(enc, "jisx0208.1978-0")) 00356 { 00357 return 19; 00358 } else if (!strcmp(enc, "jisx0212.1990-0")) { 00359 return 20; 00360 } else if (!strcmp(enc, "symbol")) { 00361 return 21; 00362 } else if (!strcmp(enc, "dingbats") || !strcmp(enc, "zapfdingbats") || 00363 !strcmp(enc, "zapf dingbats") || !strcmp(enc, "itc zapf dingbats")) 00364 { 00365 return 22; 00366 } else if (!strcmp(enc, "koi8-u")) { 00367 return 23; 00368 } else if (!strcmp(enc, "microsoft-cp1251")) { 00369 return 24; 00370 } else if (!strcmp(enc, "iso8859-11")) { 00371 return 25; 00372 } else if (!strcmp(enc, "gbk-0") || !strcmp(enc, "cp936") || !strcmp(enc, "gbk")) { 00373 return 26; 00374 }; 00375 return -1; 00376 }; 00377 00378 /* 00379 * End of "$Id$". 00380 */