fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

fl_utf.c
Go to the documentation of this file.
1 /*
2  * "$Id$"
3  *
4  * This is the utf.c file from fltk2 adapted for use in my fltk1.1 port
5  */
6 /* Copyright 2006-2015 by Bill Spitzak and others.
7  *
8  * This library is free software. Distribution and use rights are outlined in
9  * the file "COPYING" which should have been included with this file. If this
10  * file is missing or damaged, see the license at:
11  *
12  * http://www.fltk.org/COPYING.php
13  *
14  * Please report all bugs and problems on the following page:
15  *
16  * http://www.fltk.org/str.php
17  */
18 
19 /* Modified to obey rfc3629, which limits unicode to 0-0x10ffff */
20 
21 #include <FL/fl_utf8.h>
22 #include <string.h>
23 #include <stdlib.h>
24 
30 #if 0
31 
43  /* FL_EXPORT int fl_unichar_to_utf8(unsigned int uc, char *text); */
44 
57  /* FL_EXPORT int fl_utf8_size(unsigned int uc); */
58 
60 #endif /* 0 */
61 
70 #ifndef ERRORS_TO_ISO8859_1
71 # define ERRORS_TO_ISO8859_1 1
72 #endif
73 
80 #ifndef ERRORS_TO_CP1252
81 # define ERRORS_TO_CP1252 1
82 #endif
83 
90 #ifndef STRICT_RFC3629
91 # define STRICT_RFC3629 0
92 #endif
93 
94 #if ERRORS_TO_CP1252
95 /* Codes 0x80..0x9f from the Microsoft CP1252 character set, translated
96  * to Unicode:
97  */
98 static unsigned short cp1252[32] = {
99  0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
100  0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x017d, 0x008f,
101  0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
102  0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x017e, 0x0178
103 };
104 #endif
105 
137 unsigned fl_utf8decode(const char* p, const char* end, int* len)
138 {
139  unsigned char c = *(const unsigned char*)p;
140  if (c < 0x80) {
141  if (len) *len = 1;
142  return c;
143 #if ERRORS_TO_CP1252
144  } else if (c < 0xa0) {
145  if (len) *len = 1;
146  return cp1252[c-0x80];
147 #endif
148  } else if (c < 0xc2) {
149  goto FAIL;
150  }
151  if ( (end && p+1 >= end) || (p[1]&0xc0) != 0x80) goto FAIL;
152  if (c < 0xe0) {
153  if (len) *len = 2;
154  return
155  ((p[0] & 0x1f) << 6) +
156  ((p[1] & 0x3f));
157  } else if (c == 0xe0) {
158  if (((const unsigned char*)p)[1] < 0xa0) goto FAIL;
159  goto UTF8_3;
160 #if STRICT_RFC3629
161  } else if (c == 0xed) {
162  /* RFC 3629 says surrogate chars are illegal. */
163  if (((const unsigned char*)p)[1] >= 0xa0) goto FAIL;
164  goto UTF8_3;
165  } else if (c == 0xef) {
166  /* 0xfffe and 0xffff are also illegal characters */
167  if (((const unsigned char*)p)[1]==0xbf &&
168  ((const unsigned char*)p)[2]>=0xbe) goto FAIL;
169  goto UTF8_3;
170 #endif
171  } else if (c < 0xf0) {
172  UTF8_3:
173  if ( (end && p+2 >= end) || (p[2]&0xc0) != 0x80) goto FAIL;
174  if (len) *len = 3;
175  return
176  ((p[0] & 0x0f) << 12) +
177  ((p[1] & 0x3f) << 6) +
178  ((p[2] & 0x3f));
179  } else if (c == 0xf0) {
180  if (((const unsigned char*)p)[1] < 0x90) goto FAIL;
181  goto UTF8_4;
182  } else if (c < 0xf4) {
183  UTF8_4:
184  if ( (end && p+3 >= end) || (p[2]&0xc0) != 0x80 || (p[3]&0xc0) != 0x80) goto FAIL;
185  if (len) *len = 4;
186 #if STRICT_RFC3629
187  /* RFC 3629 says all codes ending in fffe or ffff are illegal: */
188  if ((p[1]&0xf)==0xf &&
189  ((const unsigned char*)p)[2] == 0xbf &&
190  ((const unsigned char*)p)[3] >= 0xbe) goto FAIL;
191 #endif
192  return
193  ((p[0] & 0x07) << 18) +
194  ((p[1] & 0x3f) << 12) +
195  ((p[2] & 0x3f) << 6) +
196  ((p[3] & 0x3f));
197  } else if (c == 0xf4) {
198  if (((const unsigned char*)p)[1] > 0x8f) goto FAIL; /* after 0x10ffff */
199  goto UTF8_4;
200  } else {
201  FAIL:
202  if (len) *len = 1;
203 #if ERRORS_TO_ISO8859_1
204  return c;
205 #else
206  return 0xfffd; /* Unicode REPLACEMENT CHARACTER */
207 #endif
208  }
209 }
210 
229 const char* fl_utf8fwd(const char* p, const char* start, const char* end)
230 {
231  const char* a;
232  int len;
233  /* if we are not pointing at a continuation character, we are done: */
234  if ((*p&0xc0) != 0x80) return p;
235  /* search backwards for a 0xc0 starting the character: */
236  for (a = p-1; ; --a) {
237  if (a < start) return p;
238  if (!(a[0]&0x80)) return p;
239  if ((a[0]&0x40)) break;
240  }
241  fl_utf8decode(a,end,&len);
242  a += len;
243  if (a > p) return a;
244  return p;
245 }
246 
260 const char* fl_utf8back(const char* p, const char* start, const char* end)
261 {
262  const char* a;
263  int len;
264  /* if we are not pointing at a continuation character, we are done: */
265  if ((*p&0xc0) != 0x80) return p;
266  /* search backwards for a 0xc0 starting the character: */
267  for (a = p-1; ; --a) {
268  if (a < start) return p;
269  if (!(a[0]&0x80)) return p;
270  if ((a[0]&0x40)) break;
271  }
272  fl_utf8decode(a,end,&len);
273  if (a+len > p) return a;
274  return p;
275 }
276 
279 int fl_utf8bytes(unsigned ucs) {
280  if (ucs < 0x000080U) {
281  return 1;
282  } else if (ucs < 0x000800U) {
283  return 2;
284  } else if (ucs < 0x010000U) {
285  return 3;
286  } else if (ucs <= 0x10ffffU) {
287  return 4;
288  } else {
289  return 3; /* length of the illegal character encoding */
290  }
291 }
292 
309 int fl_utf8encode(unsigned ucs, char* buf) {
310  if (ucs < 0x000080U) {
311  buf[0] = ucs;
312  return 1;
313  } else if (ucs < 0x000800U) {
314  buf[0] = 0xc0 | (ucs >> 6);
315  buf[1] = 0x80 | (ucs & 0x3F);
316  return 2;
317  } else if (ucs < 0x010000U) {
318  buf[0] = 0xe0 | (ucs >> 12);
319  buf[1] = 0x80 | ((ucs >> 6) & 0x3F);
320  buf[2] = 0x80 | (ucs & 0x3F);
321  return 3;
322  } else if (ucs <= 0x0010ffffU) {
323  buf[0] = 0xf0 | (ucs >> 18);
324  buf[1] = 0x80 | ((ucs >> 12) & 0x3F);
325  buf[2] = 0x80 | ((ucs >> 6) & 0x3F);
326  buf[3] = 0x80 | (ucs & 0x3F);
327  return 4;
328  } else {
329  /* encode 0xfffd: */
330  buf[0] = (char)0xef;
331  buf[1] = (char)0xbf;
332  buf[2] = (char)0xbd;
333  return 3;
334  }
335 }
336 
363 unsigned fl_ucs_to_Utf16(const unsigned ucs, unsigned short *dst, const unsigned dstlen)
364 {
365  /* The rule for direct conversion from UCS to UTF16 is:
366  * - if UCS > 0x0010FFFF then UCS is invalid
367  * - if UCS >= 0xD800 && UCS <= 0xDFFF UCS is invalid
368  * - if UCS <= 0x0000FFFF then U16 = UCS, len = 1
369  * - else
370  * -- U16[0] = ((UCS - 0x00010000) >> 10) & 0x3FF + 0xD800
371  * -- U16[1] = (UCS & 0x3FF) + 0xDC00
372  * -- len = 2;
373  */
374  unsigned count; /* Count of converted UTF16 cells */
375  unsigned short u16[4]; /* Alternate buffer if dst is not set */
376  unsigned short *out; /* points to the active buffer */
377  /* Ensure we have a valid buffer to write to */
378  if((!dstlen) || (!dst)) {
379  out = u16;
380  } else {
381  out = dst;
382  }
383  /* Convert from UCS to UTF16 */
384  if((ucs > 0x0010FFFF) || /* UCS is too large */
385  ((ucs > 0xD7FF) && (ucs < 0xE000))) { /* UCS in invalid range */
386  out[0] = 0xFFFD; /* REPLACEMENT CHARACTER */
387  count = 1;
388  } else if(ucs < 0x00010000) {
389  out[0] = (unsigned short)ucs;
390  count = 1;
391  } else if(dstlen < 2) { /* dst is too small for the result */
392  out[0] = 0xFFFD; /* REPLACEMENT CHARACTER */
393  count = 2;
394  } else {
395  out[0] = (((ucs - 0x00010000) >> 10) & 0x3FF) + 0xD800;
396  out[1] = (ucs & 0x3FF) + 0xDC00;
397  count = 2;
398  }
399  /* NULL terminate the output, if there is space */
400  if(count < dstlen) { out[count] = 0; }
401  return count;
402 } /* fl_ucs_to_Utf16 */
403 
432 unsigned fl_utf8toUtf16(const char* src, unsigned srclen,
433  unsigned short* dst, unsigned dstlen)
434 {
435  const char* p = src;
436  const char* e = src+srclen;
437  unsigned count = 0;
438  if (dstlen) for (;;) {
439  if (p >= e) {dst[count] = 0; return count;}
440  if (!(*p & 0x80)) { /* ascii */
441  dst[count] = *p++;
442  } else {
443  int len; unsigned ucs = fl_utf8decode(p,e,&len);
444  p += len;
445  if (ucs < 0x10000) {
446  dst[count] = ucs;
447  } else {
448  /* make a surrogate pair: */
449  if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
450  dst[count] = (((ucs-0x10000u)>>10)&0x3ff) | 0xd800;
451  dst[++count] = (ucs&0x3ff) | 0xdc00;
452  }
453  }
454  if (++count == dstlen) {dst[count-1] = 0; break;}
455  }
456  /* we filled dst, measure the rest: */
457  while (p < e) {
458  if (!(*p & 0x80)) p++;
459  else {
460  int len; unsigned ucs = fl_utf8decode(p,e,&len);
461  p += len;
462  if (ucs >= 0x10000) ++count;
463  }
464  ++count;
465  }
466  return count;
467 }
468 
469 
500 unsigned fl_utf8towc(const char* src, unsigned srclen,
501  wchar_t* dst, unsigned dstlen)
502 {
503 #if defined(WIN32) || defined(__CYGWIN__)
504  return fl_utf8toUtf16(src, srclen, (unsigned short*)dst, dstlen);
505 #else
506  const char* p = src;
507  const char* e = src+srclen;
508  unsigned count = 0;
509  if (dstlen) for (;;) {
510  if (p >= e) {
511  dst[count] = 0;
512  return count;
513  }
514  if (!(*p & 0x80)) { /* ascii */
515  dst[count] = *p++;
516  } else {
517  int len; unsigned ucs = fl_utf8decode(p,e,&len);
518  p += len;
519  dst[count] = (wchar_t)ucs;
520  }
521  if (++count == dstlen) {dst[count-1] = 0; break;}
522  }
523  /* we filled dst, measure the rest: */
524  while (p < e) {
525  if (!(*p & 0x80)) p++;
526  else {
527  int len; fl_utf8decode(p,e,&len);
528  p += len;
529  }
530  ++count;
531  }
532  return count;
533 #endif
534 }
535 
556 unsigned fl_utf8toa(const char* src, unsigned srclen,
557  char* dst, unsigned dstlen)
558 {
559  const char* p = src;
560  const char* e = src+srclen;
561  unsigned count = 0;
562  if (dstlen) for (;;) {
563  unsigned char c;
564  if (p >= e) {dst[count] = 0; return count;}
565  c = *(const unsigned char*)p;
566  if (c < 0xC2) { /* ascii or bad code */
567  dst[count] = c;
568  p++;
569  } else {
570  int len; unsigned ucs = fl_utf8decode(p,e,&len);
571  p += len;
572  if (ucs < 0x100) dst[count] = ucs;
573  else dst[count] = '?';
574  }
575  if (++count >= dstlen) {dst[count-1] = 0; break;}
576  }
577  /* we filled dst, measure the rest: */
578  while (p < e) {
579  if (!(*p & 0x80)) p++;
580  else {
581  int len;
582  fl_utf8decode(p,e,&len);
583  p += len;
584  }
585  ++count;
586  }
587  return count;
588 }
589 
617 unsigned fl_utf8fromwc(char* dst, unsigned dstlen,
618  const wchar_t* src, unsigned srclen) {
619  unsigned i = 0;
620  unsigned count = 0;
621  if (dstlen) for (;;) {
622  unsigned ucs;
623  if (i >= srclen) {dst[count] = 0; return count;}
624  ucs = src[i++];
625  if (ucs < 0x80U) {
626  dst[count++] = ucs;
627  if (count >= dstlen) {dst[count-1] = 0; break;}
628  } else if (ucs < 0x800U) { /* 2 bytes */
629  if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
630  dst[count++] = 0xc0 | (ucs >> 6);
631  dst[count++] = 0x80 | (ucs & 0x3F);
632 #if defined(WIN32) || defined(__CYGWIN__)
633  } else if (ucs >= 0xd800 && ucs <= 0xdbff && i < srclen &&
634  src[i] >= 0xdc00 && src[i] <= 0xdfff) {
635  /* surrogate pair */
636  unsigned ucs2 = src[i++];
637  ucs = 0x10000U + ((ucs&0x3ff)<<10) + (ucs2&0x3ff);
638  /* all surrogate pairs turn into 4-byte UTF-8 */
639 #else
640  } else if (ucs >= 0x10000) {
641  if (ucs > 0x10ffff) {
642  ucs = 0xfffd;
643  goto J1;
644  }
645 #endif
646  if (count+4 >= dstlen) {dst[count] = 0; count += 4; break;}
647  dst[count++] = 0xf0 | (ucs >> 18);
648  dst[count++] = 0x80 | ((ucs >> 12) & 0x3F);
649  dst[count++] = 0x80 | ((ucs >> 6) & 0x3F);
650  dst[count++] = 0x80 | (ucs & 0x3F);
651  } else {
652 #if !(defined(WIN32) || defined(__CYGWIN__))
653  J1:
654 #endif
655  /* all others are 3 bytes: */
656  if (count+3 >= dstlen) {dst[count] = 0; count += 3; break;}
657  dst[count++] = 0xe0 | (ucs >> 12);
658  dst[count++] = 0x80 | ((ucs >> 6) & 0x3F);
659  dst[count++] = 0x80 | (ucs & 0x3F);
660  }
661  }
662  /* we filled dst, measure the rest: */
663  while (i < srclen) {
664  unsigned ucs = src[i++];
665  if (ucs < 0x80U) {
666  count++;
667  } else if (ucs < 0x800U) { /* 2 bytes */
668  count += 2;
669 #if defined(WIN32) || defined(__CYGWIN__)
670  } else if (ucs >= 0xd800 && ucs <= 0xdbff && i < srclen-1 &&
671  src[i+1] >= 0xdc00 && src[i+1] <= 0xdfff) {
672  /* surrogate pair */
673  ++i;
674 #else
675  } else if (ucs >= 0x10000 && ucs <= 0x10ffff) {
676 #endif
677  count += 4;
678  } else {
679  count += 3;
680  }
681  }
682  return count;
683 }
684 
705 unsigned fl_utf8froma(char* dst, unsigned dstlen,
706  const char* src, unsigned srclen) {
707  const char* p = src;
708  const char* e = src+srclen;
709  unsigned count = 0;
710  if (dstlen) for (;;) {
711  unsigned char ucs;
712  if (p >= e) {dst[count] = 0; return count;}
713  ucs = *(const unsigned char*)p++;
714  if (ucs < 0x80U) {
715  dst[count++] = ucs;
716  if (count >= dstlen) {dst[count-1] = 0; break;}
717  } else { /* 2 bytes (note that CP1252 translate could make 3 bytes!) */
718  if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
719  dst[count++] = 0xc0 | (ucs >> 6);
720  dst[count++] = 0x80 | (ucs & 0x3F);
721  }
722  }
723  /* we filled dst, measure the rest: */
724  while (p < e) {
725  unsigned char ucs = *(const unsigned char*)p++;
726  if (ucs < 0x80U) {
727  count++;
728  } else {
729  count += 2;
730  }
731  }
732  return count;
733 }
734 
735 #ifdef WIN32
736 # include <windows.h>
737 #endif
738 
751 int fl_utf8locale(void) {
752  static int ret = 2;
753  if (ret == 2) {
754 #ifdef WIN32
755  ret = GetACP() == CP_UTF8;
756 #else
757  char* s;
758  ret = 1; /* assume UTF-8 if no locale */
759  if (((s = getenv("LC_CTYPE")) && *s) ||
760  ((s = getenv("LC_ALL")) && *s) ||
761  ((s = getenv("LANG")) && *s)) {
762  ret = (strstr(s,"utf") || strstr(s,"UTF"));
763  }
764 #endif
765  }
766  return ret;
767 }
768 
784 unsigned fl_utf8to_mb(const char* src, unsigned srclen,
785  char* dst, unsigned dstlen)
786 {
787  if (!fl_utf8locale()) {
788 #ifdef WIN32
789  wchar_t lbuf[1024];
790  wchar_t* buf = lbuf;
791  unsigned length = fl_utf8towc(src, srclen, buf, 1024);
792  unsigned ret;
793  if (length >= 1024) {
794  buf = (wchar_t*)(malloc((length+1)*sizeof(wchar_t)));
795  fl_utf8towc(src, srclen, buf, length+1);
796  }
797  if (dstlen) {
798  /* apparently this does not null-terminate, even though msdn
799  * documentation claims it does:
800  */
801  ret =
802  WideCharToMultiByte(GetACP(), 0, buf, length, dst, dstlen, 0, 0);
803  dst[ret] = 0;
804  }
805  /* if it overflows or measuring length, get the actual length: */
806  if (dstlen==0 || ret >= dstlen-1)
807  ret =
808  WideCharToMultiByte(GetACP(), 0, buf, length, 0, 0, 0, 0);
809  if (buf != lbuf) free((void*)buf);
810  return ret;
811 #else
812  wchar_t lbuf[1024];
813  wchar_t* buf = lbuf;
814  unsigned length = fl_utf8towc(src, srclen, buf, 1024);
815  int ret; /* note: wcstombs() returns unsigned(length) or unsigned(-1) */
816  if (length >= 1024) {
817  buf = (wchar_t*)(malloc((length+1)*sizeof(wchar_t)));
818  fl_utf8towc(src, srclen, buf, length+1);
819  }
820  if (dstlen) {
821  ret = wcstombs(dst, buf, dstlen);
822  if (ret >= (int)dstlen-1) ret = wcstombs(0,buf,0);
823  } else {
824  ret = wcstombs(0,buf,0);
825  }
826  if (buf != lbuf) free((void*)buf);
827  if (ret >= 0) return (unsigned)ret;
828  /* on any errors we return the UTF-8 as raw text...*/
829 #endif
830  }
831  /* identity transform: */
832  if (srclen < dstlen) {
833  memcpy(dst, src, srclen);
834  dst[srclen] = 0;
835  } else {
836  /* Buffer insufficent or buffer query */
837  }
838  return srclen;
839 }
840 
858 unsigned fl_utf8from_mb(char* dst, unsigned dstlen,
859  const char* src, unsigned srclen)
860 {
861  if (!fl_utf8locale()) {
862 #ifdef WIN32
863  wchar_t lbuf[1024];
864  wchar_t* buf = lbuf;
865  unsigned length;
866  unsigned ret;
867  length = MultiByteToWideChar(GetACP(), 0, src, srclen, buf, 1024);
868  if ((length == 0)&&(GetLastError()==ERROR_INSUFFICIENT_BUFFER)) {
869  length = MultiByteToWideChar(GetACP(), 0, src, srclen, 0, 0);
870  buf = (wchar_t*)(malloc(length*sizeof(wchar_t)));
871  MultiByteToWideChar(GetACP(), 0, src, srclen, buf, length);
872  }
873  ret = fl_utf8fromwc(dst, dstlen, buf, length);
874  if (buf != lbuf) free((void*)buf);
875  return ret;
876 #else
877  wchar_t lbuf[1024];
878  wchar_t* buf = lbuf;
879  int length;
880  unsigned ret;
881  length = mbstowcs(buf, src, 1024);
882  if (length >= 1024) {
883  length = mbstowcs(0, src, 0)+1;
884  buf = (wchar_t*)(malloc(length*sizeof(wchar_t)));
885  mbstowcs(buf, src, length);
886  }
887  if (length >= 0) {
888  ret = fl_utf8fromwc(dst, dstlen, buf, length);
889  if (buf != lbuf) free((void*)buf);
890  return ret;
891  }
892  /* errors in conversion return the UTF-8 unchanged */
893 #endif
894  }
895  /* identity transform: */
896  if (srclen < dstlen) {
897  memcpy(dst, src, srclen);
898  dst[srclen] = 0;
899  } else {
900  /* Buffer insufficent or buffer query */
901  }
902  return srclen;
903 }
904 
925 int fl_utf8test(const char* src, unsigned srclen) {
926  int ret = 1;
927  const char* p = src;
928  const char* e = src+srclen;
929  while (p < e) {
930  if (*p & 0x80) {
931  int len; fl_utf8decode(p,e,&len);
932  if (len < 2) return 0;
933  if (len > ret) ret = len;
934  p += len;
935  } else {
936  p++;
937  }
938  }
939  return ret;
940 }
941 
942 /* forward declare mk_wcwidth() as static so the name is not visible.
943  */
944  static int mk_wcwidth(unsigned int ucs);
945 
946  /* include the c source directly so it's contents are only visible here
947  */
948 #include "xutf8/mk_wcwidth.c"
949 
963 int fl_wcwidth_(unsigned int ucs) {
964  return mk_wcwidth(ucs);
965 }
966 
980 int fl_wcwidth(const char* src) {
981  int len = fl_utf8len(*src);
982  int ret = 0;
983  unsigned int ucs = fl_utf8decode(src, src+len, &ret);
984  int width = fl_wcwidth_(ucs);
985  return width;
986 }
987 
990 /*
991  * End of "$Id$".
992  */
buf
static char * buf
Definition: fl_encoding_mac_roman.cxx:76
fl_utf8towc
unsigned fl_utf8towc(const char *src, unsigned srclen, wchar_t *dst, unsigned dstlen)
Definition: fl_utf.c:500
fl_utf8toUtf16
unsigned fl_utf8toUtf16(const char *src, unsigned srclen, unsigned short *dst, unsigned dstlen)
Definition: fl_utf.c:432
fl_utf8len
int fl_utf8len(char c)
Definition: fl_utf8.cxx:111
fl_utf8toa
unsigned fl_utf8toa(const char *src, unsigned srclen, char *dst, unsigned dstlen)
Definition: fl_utf.c:556
free
void free()
fl_wcwidth
int fl_wcwidth(const char *src)
Definition: fl_utf.c:980
fl_utf8fromwc
unsigned fl_utf8fromwc(char *dst, unsigned dstlen, const wchar_t *src, unsigned srclen)
Definition: fl_utf.c:617
mk_wcwidth
static int mk_wcwidth(unsigned int ucs)
Definition: mk_wcwidth.c:144
fl_utf8fwd
const char * fl_utf8fwd(const char *p, const char *start, const char *end)
Definition: fl_utf.c:229
fl_utf8decode
unsigned fl_utf8decode(const char *p, const char *end, int *len)
Definition: fl_utf.c:137
fl_utf8froma
unsigned fl_utf8froma(char *dst, unsigned dstlen, const char *src, unsigned srclen)
Definition: fl_utf.c:705
p
static menustate * p
Definition: Fl_Menu.cxx:606
fl_utf8.h
header for Unicode and UTF-8 character handling
fl_utf8from_mb
unsigned fl_utf8from_mb(char *dst, unsigned dstlen, const char *src, unsigned srclen)
Definition: fl_utf.c:858
fl_utf8bytes
int fl_utf8bytes(unsigned ucs)
Definition: fl_utf.c:279
fl_utf8locale
int fl_utf8locale(void)
Definition: fl_utf.c:751
fl_utf8test
int fl_utf8test(const char *src, unsigned len)
Definition: fl_utf.c:925
fl_utf8encode
int fl_utf8encode(unsigned ucs, char *buf)
Definition: fl_utf.c:309
malloc
voidp malloc()
cp1252
static unsigned short cp1252[32]
Definition: fl_utf.c:98
fl_utf8back
const char * fl_utf8back(const char *p, const char *start, const char *end)
Definition: fl_utf.c:260
length
png_uint_32 length
Definition: png.c:2173
start
static int start(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int w, int h, int &cx, int &cy, int &X, int &Y, int &W, int &H)
Definition: Fl_Image.cxx:655
fl_ucs_to_Utf16
unsigned fl_ucs_to_Utf16(const unsigned ucs, unsigned short *dst, const unsigned dstlen)
Definition: fl_utf.c:363
fl_wcwidth_
int fl_wcwidth_(unsigned int ucs)
Definition: fl_utf.c:963
fl_utf8to_mb
unsigned fl_utf8to_mb(const char *src, unsigned srclen, char *dst, unsigned dstlen)
Definition: fl_utf.c:784
mk_wcwidth.c