Fixes for SGI builds (STR#2174)
1) C++ style comments in C files converted to /* */ 2) #warning's had to be #ifdef'ed out (#if !defined(sgi)..) With these mods, 1.3.x compiles on IRIX 6.5 with no failures. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6680 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
923479622f
commit
50a92455fe
@ -33,7 +33,7 @@
|
|||||||
/** \addtogroup filenames File names and URI utility functions
|
/** \addtogroup filenames File names and URI utility functions
|
||||||
@{ */
|
@{ */
|
||||||
|
|
||||||
# define FL_PATH_MAX 256 ///< all path buffers should use this length
|
# define FL_PATH_MAX 256 /**< all path buffers should use this length */
|
||||||
/** Gets the file name from a path. \return a pointer to the char after the last slash, or to \a filename if there is none. */
|
/** Gets the file name from a path. \return a pointer to the char after the last slash, or to \a filename if there is none. */
|
||||||
FL_EXPORT const char *fl_filename_name(const char * filename);
|
FL_EXPORT const char *fl_filename_name(const char * filename);
|
||||||
FL_EXPORT const char *fl_filename_ext(const char *);
|
FL_EXPORT const char *fl_filename_ext(const char *);
|
||||||
@ -105,7 +105,7 @@ FL_EXPORT int fl_casenumericsort(struct dirent **, struct dirent **);
|
|||||||
FL_EXPORT int fl_numericsort(struct dirent **, struct dirent **);
|
FL_EXPORT int fl_numericsort(struct dirent **, struct dirent **);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **); ///< File sorting function. \see fl_filename_list()
|
typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **); /**< File sorting function. \see fl_filename_list() */
|
||||||
|
|
||||||
# if defined(__cplusplus)
|
# if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
//
|
/*
|
||||||
// "$Id: fl_types.h 6299 2008-09-18 19:09:34Z fabien $"
|
* "$Id: fl_types.h 6299 2008-09-18 19:09:34Z fabien $"
|
||||||
//
|
*
|
||||||
// Simple "C"-style types for the Fast Light Tool Kit (FLTK).
|
* Simple "C"-style types for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
*
|
||||||
// Copyright 1998-2009 by Bill Spitzak and others.
|
* Copyright 1998-2009 by Bill Spitzak and others.
|
||||||
//
|
*
|
||||||
// This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
// License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
// version 2 of the License, or (at your option) any later version.
|
* version 2 of the License, or (at your option) any later version.
|
||||||
//
|
*
|
||||||
// This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// Library General Public License for more details.
|
* Library General Public License for more details.
|
||||||
//
|
*
|
||||||
// You should have received a copy of the GNU Library General Public
|
* You should have received a copy of the GNU Library General Public
|
||||||
// License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
// USA.
|
* USA.
|
||||||
//
|
*
|
||||||
// Please report all bugs and problems on the following page:
|
* Please report all bugs and problems on the following page:
|
||||||
//
|
*
|
||||||
// http://www.fltk.org/str.php
|
* http://www.fltk.org/str.php
|
||||||
//
|
*/
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
* This file contains simple "C"-style type definitions.
|
* This file contains simple "C"-style type definitions.
|
||||||
@ -33,7 +33,7 @@
|
|||||||
#define FL_TYPES_H
|
#define FL_TYPES_H
|
||||||
|
|
||||||
/** \name Miscellaneous */
|
/** \name Miscellaneous */
|
||||||
/*@{*/ // group: Miscellaneous
|
/*@{*/ /* group: Miscellaneous */
|
||||||
|
|
||||||
/** unsigned char */
|
/** unsigned char */
|
||||||
typedef unsigned char uchar;
|
typedef unsigned char uchar;
|
||||||
@ -54,10 +54,10 @@ typedef const char *Fl_CString;
|
|||||||
/** 24-bit Unicode character + 8-bit indicator for keyboard flags */
|
/** 24-bit Unicode character + 8-bit indicator for keyboard flags */
|
||||||
typedef unsigned int Fl_Unichar;
|
typedef unsigned int Fl_Unichar;
|
||||||
|
|
||||||
/*@}*/ // group: Miscellaneous
|
/*@}*/ /* group: Miscellaneous */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
/*
|
||||||
// End of "$Id: fl_types.h 6299 2008-09-18 19:09:34Z fabien $".
|
* End of "$Id: fl_types.h 6299 2008-09-18 19:09:34Z fabien $".
|
||||||
//
|
*/
|
||||||
|
76
FL/fl_utf8.h
76
FL/fl_utf8.h
@ -1,31 +1,32 @@
|
|||||||
// "$Id: $"
|
/* "$Id: $"
|
||||||
//
|
*
|
||||||
// Author: Jean-Marc Lienher ( http://oksid.ch )
|
* Author: Jean-Marc Lienher ( http://oksid.ch )
|
||||||
// Copyright 2000-2009 by O'ksi'D.
|
* Copyright 2000-2009 by O'ksi'D.
|
||||||
//
|
*
|
||||||
// This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
// License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
// version 2 of the License, or (at your option) any later version.
|
* version 2 of the License, or (at your option) any later version.
|
||||||
//
|
*
|
||||||
// This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// Library General Public License for more details.
|
* Library General Public License for more details.
|
||||||
//
|
*
|
||||||
// You should have received a copy of the GNU Library General Public
|
* You should have received a copy of the GNU Library General Public
|
||||||
// License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
// USA.
|
* USA.
|
||||||
//
|
*
|
||||||
// Please report all bugs and problems on the following page:
|
* Please report all bugs and problems on the following page:
|
||||||
//
|
*
|
||||||
// http://www.fltk.org/str.php
|
* http://www.fltk.org/str.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Merged in some functionality from the fltk-2 version. IMM.
|
||||||
// Merged in some functionality from the fltk-2 version. IMM.
|
* The following code is an attempt to merge the functions incorporated in FLTK2
|
||||||
// The following code is an attempt to merge the functions incorporated in FLTK2
|
* with the functions provided in OksiD's fltk-1.1.6-utf8 port
|
||||||
// with the functions provided in OksiD's fltk-1.1.6-utf8 port
|
*/
|
||||||
|
|
||||||
/*** NOTE : all functions are LIMITED to 24 bits Unicode values !!! ***/
|
/*** NOTE : all functions are LIMITED to 24 bits Unicode values !!! ***/
|
||||||
|
|
||||||
@ -115,12 +116,12 @@ FL_EXPORT unsigned fl_utf8fromwc(char *dst, unsigned dstlen, const wchar_t *src,
|
|||||||
/* F2: Convert a UTF8 string into ASCII, eliding untranslatable glyphs */
|
/* F2: Convert a UTF8 string into ASCII, eliding untranslatable glyphs */
|
||||||
FL_EXPORT unsigned fl_utf8toa (const char *src, unsigned srclen, char *dst, unsigned dstlen);
|
FL_EXPORT unsigned fl_utf8toa (const char *src, unsigned srclen, char *dst, unsigned dstlen);
|
||||||
/* OD: convert UTF-8 string to latin1 */
|
/* OD: convert UTF-8 string to latin1 */
|
||||||
//FL_EXPORT int fl_utf2latin1(const unsigned char *src, int srclen, char *dst);
|
/* FL_EXPORT int fl_utf2latin1(const unsigned char *src, int srclen, char *dst); */
|
||||||
|
|
||||||
/* F2: Convert 8859-1 string to UTF8 */
|
/* F2: Convert 8859-1 string to UTF8 */
|
||||||
FL_EXPORT unsigned fl_utf8froma (char *dst, unsigned dstlen, const char *src, unsigned srclen);
|
FL_EXPORT unsigned fl_utf8froma (char *dst, unsigned dstlen, const char *src, unsigned srclen);
|
||||||
/* OD: convert latin1 str to UTF-8 */
|
/* OD: convert latin1 str to UTF-8 */
|
||||||
//FL_EXPORT int fl_latin12utf(const unsigned char *src, int srclen, char *dst);
|
/* FL_EXPORT int fl_latin12utf(const unsigned char *src, int srclen, char *dst); */
|
||||||
|
|
||||||
/* F2: Returns true if the current O/S locale is UTF8 */
|
/* F2: Returns true if the current O/S locale is UTF8 */
|
||||||
FL_EXPORT int fl_utf8locale();
|
FL_EXPORT int fl_utf8locale();
|
||||||
@ -141,7 +142,7 @@ FL_EXPORT char* fl_utf2mbcs(const char *src);
|
|||||||
/* F2: Convert a local multi-byte encoding to UTF8 - mainly for win32? */
|
/* F2: Convert a local multi-byte encoding to UTF8 - mainly for win32? */
|
||||||
FL_EXPORT unsigned fl_utf8from_mb(char *dst, unsigned dstlen, const char *src, unsigned srclen);
|
FL_EXPORT unsigned fl_utf8from_mb(char *dst, unsigned dstlen, const char *src, unsigned srclen);
|
||||||
/* OD: Convert a local multi-byte encoding to UTF8 */
|
/* OD: Convert a local multi-byte encoding to UTF8 */
|
||||||
//FL_EXPORT char* fl_mbcs2utf(const char *src);
|
/* FL_EXPORT char* fl_mbcs2utf(const char *src); */
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -152,9 +153,10 @@ FL_EXPORT char *fl_utf8_to_locale(const char *s, int len, unsigned int codepage)
|
|||||||
FL_EXPORT char *fl_locale_to_utf8(const char *s, int len, unsigned int codepage);
|
FL_EXPORT char *fl_locale_to_utf8(const char *s, int len, unsigned int codepage);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************
|
||||||
// The following functions are intended to provide portable, UTF8 aware
|
* The following functions are intended to provide portable, UTF8 aware
|
||||||
// versions of standard functions
|
* versions of standard functions
|
||||||
|
*/
|
||||||
|
|
||||||
/* OD: UTF8 aware strncasecmp - converts to lower case Unicode and tests */
|
/* OD: UTF8 aware strncasecmp - converts to lower case Unicode and tests */
|
||||||
FL_EXPORT int fl_utf_strncasecmp(const char *s1, const char *s2, int n);
|
FL_EXPORT int fl_utf_strncasecmp(const char *s1, const char *s2, int n);
|
||||||
@ -227,8 +229,8 @@ FL_EXPORT char fl_make_path( const char *path );
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
#endif // _HAVE_FL_UTF8_HDR_
|
#endif /* _HAVE_FL_UTF8_HDR_ */
|
||||||
|
|
||||||
//
|
/*
|
||||||
// End of "$Id: $".
|
* End of "$Id: $".
|
||||||
//
|
*/
|
||||||
|
@ -64,7 +64,7 @@ extern int main(int, char *[]);
|
|||||||
# define __argv _argv
|
# define __argv _argv
|
||||||
# endif /* BORLAND5 */
|
# endif /* BORLAND5 */
|
||||||
|
|
||||||
//static int mbcs2utf(const char *s, int l, char *dst, unsigned dstlen)
|
/* static int mbcs2utf(const char *s, int l, char *dst, unsigned dstlen) */
|
||||||
static int mbcs2utf(const char *s, int l, char *dst)
|
static int mbcs2utf(const char *s, int l, char *dst)
|
||||||
{
|
{
|
||||||
static xchar *mbwbuf;
|
static xchar *mbwbuf;
|
||||||
@ -73,7 +73,7 @@ static int mbcs2utf(const char *s, int l, char *dst)
|
|||||||
dstlen = (l * 6) + 6;
|
dstlen = (l * 6) + 6;
|
||||||
mbwbuf = (xchar*)malloc(dstlen * sizeof(xchar));
|
mbwbuf = (xchar*)malloc(dstlen * sizeof(xchar));
|
||||||
l = mbstowcs(mbwbuf, s, l);
|
l = mbstowcs(mbwbuf, s, l);
|
||||||
//l = fl_unicode2utf(mbwbuf, l, dst);
|
/* l = fl_unicode2utf(mbwbuf, l, dst); */
|
||||||
l = fl_utf8fromwc(dst, dstlen, mbwbuf, l);
|
l = fl_utf8fromwc(dst, dstlen, mbwbuf, l);
|
||||||
dst[l] = 0;
|
dst[l] = 0;
|
||||||
free(mbwbuf);
|
free(mbwbuf);
|
||||||
@ -108,17 +108,17 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
int l;
|
int l;
|
||||||
unsigned dstlen;
|
unsigned dstlen;
|
||||||
if (__wargv ) {
|
if (__wargv ) {
|
||||||
for (l = 0; __wargv[i] && __wargv[i][l]; l++) {}; // is this just wstrlen???
|
for (l = 0; __wargv[i] && __wargv[i][l]; l++) {}; /* is this just wstrlen??? */
|
||||||
dstlen = (l * 5) + 1;
|
dstlen = (l * 5) + 1;
|
||||||
ar[i] = (char*) malloc(dstlen);
|
ar[i] = (char*) malloc(dstlen);
|
||||||
// ar[i][fl_unicode2utf(__wargv[i], l, ar[i])] = 0;
|
/* ar[i][fl_unicode2utf(__wargv[i], l, ar[i])] = 0; */
|
||||||
dstlen = fl_utf8fromwc(ar[i], dstlen, __wargv[i], l);
|
dstlen = fl_utf8fromwc(ar[i], dstlen, __wargv[i], l);
|
||||||
ar[i][dstlen] = 0;
|
ar[i][dstlen] = 0;
|
||||||
} else {
|
} else {
|
||||||
for (l = 0; __argv[i] && __argv[i][l]; l++) {};
|
for (l = 0; __argv[i] && __argv[i][l]; l++) {};
|
||||||
dstlen = (l * 5) + 1;
|
dstlen = (l * 5) + 1;
|
||||||
ar[i] = (char*) malloc(dstlen);
|
ar[i] = (char*) malloc(dstlen);
|
||||||
// ar[i][mbcs2utf(__argv[i], l, ar[i], dstlen)] = 0;
|
/* ar[i][mbcs2utf(__argv[i], l, ar[i], dstlen)] = 0; */
|
||||||
ar[i][mbcs2utf(__argv[i], l, ar[i])] = 0;
|
ar[i][mbcs2utf(__argv[i], l, ar[i])] = 0;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@ -139,7 +139,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
#elif defined(__hpux)
|
#elif defined(__hpux)
|
||||||
/* This code to prevent "empty translation unit" or similar warnings... */
|
/* This code to prevent "empty translation unit" or similar warnings... */
|
||||||
static void dummy(void) {}
|
static void dummy(void) {}
|
||||||
#endif // WIN32 && !FL_DLL && !__GNUC__
|
#endif /* WIN32 && !FL_DLL && !__GNUC__ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End of "$Id$".
|
* End of "$Id$".
|
||||||
|
@ -298,7 +298,11 @@ double fl_width(unsigned int c) {
|
|||||||
|
|
||||||
|
|
||||||
void fl_text_extents(const char *c, int n, int &dx, int &dy, int &W, int &H) {
|
void fl_text_extents(const char *c, int n, int &dx, int &dy, int &W, int &H) {
|
||||||
|
|
||||||
|
#if !defined(WIN32) && !defined(sgi) || defined(CYGWIN)
|
||||||
#warning fl_text_extents is only a test stub in Xlib build at present
|
#warning fl_text_extents is only a test stub in Xlib build at present
|
||||||
|
#endif
|
||||||
|
|
||||||
W = 0; H = 0;
|
W = 0; H = 0;
|
||||||
fl_measure(c, W, H, 0);
|
fl_measure(c, W, H, 0);
|
||||||
dx = 0;
|
dx = 0;
|
||||||
|
84
src/fl_utf.c
84
src/fl_utf.c
@ -22,7 +22,7 @@
|
|||||||
* http://www.fltk.org/str.php
|
* http://www.fltk.org/str.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Modified to obey rfc3629, which limits unicode to 0-0x10ffff
|
/* Modified to obey rfc3629, which limits unicode to 0-0x10ffff */
|
||||||
|
|
||||||
#include <FL/fl_utf8.h>
|
#include <FL/fl_utf8.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -41,7 +41,7 @@
|
|||||||
\c NULL, only the length of the utf-8 sequence is calculated
|
\c NULL, only the length of the utf-8 sequence is calculated
|
||||||
\return length of the sequence in bytes
|
\return length of the sequence in bytes
|
||||||
*/
|
*/
|
||||||
//FL_EXPORT int fl_unichar_to_utf8(Fl_Unichar uc, char *text);
|
/* FL_EXPORT int fl_unichar_to_utf8(Fl_Unichar uc, char *text); */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
@ -55,10 +55,10 @@
|
|||||||
\param[in] uc Unicode character
|
\param[in] uc Unicode character
|
||||||
\return length of the sequence in bytes
|
\return length of the sequence in bytes
|
||||||
*/
|
*/
|
||||||
//FL_EXPORT int fl_utf8_size(Fl_Unichar uc);
|
/* FL_EXPORT int fl_utf8_size(Fl_Unichar uc); */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
#endif // 0
|
#endif /* 0 */
|
||||||
|
|
||||||
/* Set to 1 to turn bad UTF8 bytes into ISO-8859-1. If this is to zero
|
/* Set to 1 to turn bad UTF8 bytes into ISO-8859-1. If this is to zero
|
||||||
they are instead turned into the Unicode REPLACEMENT CHARACTER, of
|
they are instead turned into the Unicode REPLACEMENT CHARACTER, of
|
||||||
@ -87,8 +87,9 @@
|
|||||||
#define STRICT_RFC3629 0
|
#define STRICT_RFC3629 0
|
||||||
|
|
||||||
#if ERRORS_TO_CP1252
|
#if ERRORS_TO_CP1252
|
||||||
// Codes 0x80..0x9f from the Microsoft CP1252 character set, translated
|
/* Codes 0x80..0x9f from the Microsoft CP1252 character set, translated
|
||||||
// to Unicode:
|
* to Unicode:
|
||||||
|
*/
|
||||||
static unsigned short cp1252[32] = {
|
static unsigned short cp1252[32] = {
|
||||||
0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
|
0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
|
||||||
0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x017d, 0x008f,
|
0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x017d, 0x008f,
|
||||||
@ -153,11 +154,11 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
|
|||||||
goto UTF8_3;
|
goto UTF8_3;
|
||||||
#if STRICT_RFC3629
|
#if STRICT_RFC3629
|
||||||
} else if (c == 0xed) {
|
} else if (c == 0xed) {
|
||||||
// RFC 3629 says surrogate chars are illegal.
|
/* RFC 3629 says surrogate chars are illegal. */
|
||||||
if (((unsigned char*)p)[1] >= 0xa0) goto FAIL;
|
if (((unsigned char*)p)[1] >= 0xa0) goto FAIL;
|
||||||
goto UTF8_3;
|
goto UTF8_3;
|
||||||
} else if (c == 0xef) {
|
} else if (c == 0xef) {
|
||||||
// 0xfffe and 0xffff are also illegal characters
|
/* 0xfffe and 0xffff are also illegal characters */
|
||||||
if (((unsigned char*)p)[1]==0xbf &&
|
if (((unsigned char*)p)[1]==0xbf &&
|
||||||
((unsigned char*)p)[2]>=0xbe) goto FAIL;
|
((unsigned char*)p)[2]>=0xbe) goto FAIL;
|
||||||
goto UTF8_3;
|
goto UTF8_3;
|
||||||
@ -178,7 +179,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
|
|||||||
if (p+3 >= end || (p[2]&0xc0) != 0x80 || (p[3]&0xc0) != 0x80) goto FAIL;
|
if (p+3 >= end || (p[2]&0xc0) != 0x80 || (p[3]&0xc0) != 0x80) goto FAIL;
|
||||||
*len = 4;
|
*len = 4;
|
||||||
#if STRICT_RFC3629
|
#if STRICT_RFC3629
|
||||||
// RFC 3629 says all codes ending in fffe or ffff are illegal:
|
/* RFC 3629 says all codes ending in fffe or ffff are illegal: */
|
||||||
if ((p[1]&0xf)==0xf &&
|
if ((p[1]&0xf)==0xf &&
|
||||||
((unsigned char*)p)[2] == 0xbf &&
|
((unsigned char*)p)[2] == 0xbf &&
|
||||||
((unsigned char*)p)[3] >= 0xbe) goto FAIL;
|
((unsigned char*)p)[3] >= 0xbe) goto FAIL;
|
||||||
@ -189,7 +190,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
|
|||||||
((p[2] & 0x3f) << 6) +
|
((p[2] & 0x3f) << 6) +
|
||||||
((p[3] & 0x3f));
|
((p[3] & 0x3f));
|
||||||
} else if (c == 0xf4) {
|
} else if (c == 0xf4) {
|
||||||
if (((unsigned char*)p)[1] > 0x8f) goto FAIL; // after 0x10ffff
|
if (((unsigned char*)p)[1] > 0x8f) goto FAIL; /* after 0x10ffff */
|
||||||
goto UTF8_4;
|
goto UTF8_4;
|
||||||
} else {
|
} else {
|
||||||
FAIL:
|
FAIL:
|
||||||
@ -197,7 +198,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
|
|||||||
#if ERRORS_TO_ISO8859_1
|
#if ERRORS_TO_ISO8859_1
|
||||||
return c;
|
return c;
|
||||||
#else
|
#else
|
||||||
return 0xfffd; // Unicode REPLACEMENT CHARACTER
|
return 0xfffd; /* Unicode REPLACEMENT CHARACTER */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,9 +225,9 @@ const char* fl_utf8fwd(const char* p, const char* start, const char* end)
|
|||||||
{
|
{
|
||||||
const char* a;
|
const char* a;
|
||||||
int len;
|
int len;
|
||||||
// if we are not pointing at a continuation character, we are done:
|
/* if we are not pointing at a continuation character, we are done: */
|
||||||
if ((*p&0xc0) != 0x80) return p;
|
if ((*p&0xc0) != 0x80) return p;
|
||||||
// search backwards for a 0xc0 starting the character:
|
/* search backwards for a 0xc0 starting the character: */
|
||||||
for (a = p-1; ; --a) {
|
for (a = p-1; ; --a) {
|
||||||
if (a < start) return p;
|
if (a < start) return p;
|
||||||
if (!(a[0]&0x80)) return p;
|
if (!(a[0]&0x80)) return p;
|
||||||
@ -255,9 +256,9 @@ const char* fl_utf8back(const char* p, const char* start, const char* end)
|
|||||||
{
|
{
|
||||||
const char* a;
|
const char* a;
|
||||||
int len;
|
int len;
|
||||||
// if we are not pointing at a continuation character, we are done:
|
/* if we are not pointing at a continuation character, we are done: */
|
||||||
if ((*p&0xc0) != 0x80) return p;
|
if ((*p&0xc0) != 0x80) return p;
|
||||||
// search backwards for a 0xc0 starting the character:
|
/* search backwards for a 0xc0 starting the character: */
|
||||||
for (a = p-1; ; --a) {
|
for (a = p-1; ; --a) {
|
||||||
if (a < start) return p;
|
if (a < start) return p;
|
||||||
if (!(a[0]&0x80)) return p;
|
if (!(a[0]&0x80)) return p;
|
||||||
@ -280,7 +281,7 @@ int fl_utf8bytes(unsigned ucs) {
|
|||||||
} else if (ucs < 0x10ffffU) {
|
} else if (ucs < 0x10ffffU) {
|
||||||
return 4;
|
return 4;
|
||||||
} else {
|
} else {
|
||||||
return 3; // length of the illegal character encoding
|
return 3; /* length of the illegal character encoding */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +321,7 @@ int fl_utf8encode(unsigned ucs, char* buf) {
|
|||||||
buf[3] = 0x80 | (ucs & 0x3F);
|
buf[3] = 0x80 | (ucs & 0x3F);
|
||||||
return 4;
|
return 4;
|
||||||
} else {
|
} else {
|
||||||
// encode 0xfffd:
|
/* encode 0xfffd: */
|
||||||
buf[0] = 0xefU;
|
buf[0] = 0xefU;
|
||||||
buf[1] = 0xbfU;
|
buf[1] = 0xbfU;
|
||||||
buf[2] = 0xbdU;
|
buf[2] = 0xbdU;
|
||||||
@ -367,7 +368,7 @@ unsigned fl_utf8toUtf16(const char* src, unsigned srclen,
|
|||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
if (dstlen) for (;;) {
|
if (dstlen) for (;;) {
|
||||||
if (p >= e) {dst[count] = 0; return count;}
|
if (p >= e) {dst[count] = 0; return count;}
|
||||||
if (!(*p & 0x80)) { // ascii
|
if (!(*p & 0x80)) { /* ascii */
|
||||||
dst[count] = *p++;
|
dst[count] = *p++;
|
||||||
} else {
|
} else {
|
||||||
int len; unsigned ucs = fl_utf8decode(p,e,&len);
|
int len; unsigned ucs = fl_utf8decode(p,e,&len);
|
||||||
@ -375,7 +376,7 @@ unsigned fl_utf8toUtf16(const char* src, unsigned srclen,
|
|||||||
if (ucs < 0x10000) {
|
if (ucs < 0x10000) {
|
||||||
dst[count] = ucs;
|
dst[count] = ucs;
|
||||||
} else {
|
} else {
|
||||||
// make a surrogate pair:
|
/* make a surrogate pair: */
|
||||||
if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
|
if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
|
||||||
dst[count] = (((ucs-0x10000u)>>10)&0x3ff) | 0xd800;
|
dst[count] = (((ucs-0x10000u)>>10)&0x3ff) | 0xd800;
|
||||||
dst[++count] = (ucs&0x3ff) | 0xdc00;
|
dst[++count] = (ucs&0x3ff) | 0xdc00;
|
||||||
@ -383,7 +384,7 @@ unsigned fl_utf8toUtf16(const char* src, unsigned srclen,
|
|||||||
}
|
}
|
||||||
if (++count == dstlen) {dst[count-1] = 0; break;}
|
if (++count == dstlen) {dst[count-1] = 0; break;}
|
||||||
}
|
}
|
||||||
// we filled dst, measure the rest:
|
/* we filled dst, measure the rest: */
|
||||||
while (p < e) {
|
while (p < e) {
|
||||||
if (!(*p & 0x80)) p++;
|
if (!(*p & 0x80)) p++;
|
||||||
else {
|
else {
|
||||||
@ -410,7 +411,7 @@ unsigned fl_utf8towc(const char* src, unsigned srclen,
|
|||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
if (dstlen) for (;;) {
|
if (dstlen) for (;;) {
|
||||||
if (p >= e) {dst[count] = 0; return count;}
|
if (p >= e) {dst[count] = 0; return count;}
|
||||||
if (!(*p & 0x80)) { // ascii
|
if (!(*p & 0x80)) { /* ascii */
|
||||||
dst[count] = *p++;
|
dst[count] = *p++;
|
||||||
} else {
|
} else {
|
||||||
int len; unsigned ucs = fl_utf8decode(p,e,&len);
|
int len; unsigned ucs = fl_utf8decode(p,e,&len);
|
||||||
@ -419,7 +420,7 @@ unsigned fl_utf8towc(const char* src, unsigned srclen,
|
|||||||
}
|
}
|
||||||
if (++count == dstlen) {dst[count-1] = 0; break;}
|
if (++count == dstlen) {dst[count-1] = 0; break;}
|
||||||
}
|
}
|
||||||
// we filled dst, measure the rest:
|
/* we filled dst, measure the rest: */
|
||||||
while (p < e) {
|
while (p < e) {
|
||||||
if (!(*p & 0x80)) p++;
|
if (!(*p & 0x80)) p++;
|
||||||
else {
|
else {
|
||||||
@ -462,7 +463,7 @@ unsigned fl_utf8toa(const char* src, unsigned srclen,
|
|||||||
unsigned char c;
|
unsigned char c;
|
||||||
if (p >= e) {dst[count] = 0; return count;}
|
if (p >= e) {dst[count] = 0; return count;}
|
||||||
c = *(unsigned char*)p;
|
c = *(unsigned char*)p;
|
||||||
if (c < 0xC2) { // ascii or bad code
|
if (c < 0xC2) { /* ascii or bad code */
|
||||||
dst[count] = c;
|
dst[count] = c;
|
||||||
p++;
|
p++;
|
||||||
} else {
|
} else {
|
||||||
@ -473,7 +474,7 @@ unsigned fl_utf8toa(const char* src, unsigned srclen,
|
|||||||
}
|
}
|
||||||
if (++count >= dstlen) {dst[count-1] = 0; break;}
|
if (++count >= dstlen) {dst[count-1] = 0; break;}
|
||||||
}
|
}
|
||||||
// we filled dst, measure the rest:
|
/* we filled dst, measure the rest: */
|
||||||
while (p < e) {
|
while (p < e) {
|
||||||
if (!(*p & 0x80)) p++;
|
if (!(*p & 0x80)) p++;
|
||||||
else {
|
else {
|
||||||
@ -524,17 +525,17 @@ unsigned fl_utf8fromwc(char* dst, unsigned dstlen,
|
|||||||
if (ucs < 0x80U) {
|
if (ucs < 0x80U) {
|
||||||
dst[count++] = ucs;
|
dst[count++] = ucs;
|
||||||
if (count >= dstlen) {dst[count-1] = 0; break;}
|
if (count >= dstlen) {dst[count-1] = 0; break;}
|
||||||
} else if (ucs < 0x800U) { // 2 bytes
|
} else if (ucs < 0x800U) { /* 2 bytes */
|
||||||
if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
|
if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
|
||||||
dst[count++] = 0xc0 | (ucs >> 6);
|
dst[count++] = 0xc0 | (ucs >> 6);
|
||||||
dst[count++] = 0x80 | (ucs & 0x3F);
|
dst[count++] = 0x80 | (ucs & 0x3F);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
} else if (ucs >= 0xd800 && ucs <= 0xdbff && i < srclen &&
|
} else if (ucs >= 0xd800 && ucs <= 0xdbff && i < srclen &&
|
||||||
src[i] >= 0xdc00 && src[i] <= 0xdfff) {
|
src[i] >= 0xdc00 && src[i] <= 0xdfff) {
|
||||||
// surrogate pair
|
/* surrogate pair */
|
||||||
unsigned ucs2 = src[i++];
|
unsigned ucs2 = src[i++];
|
||||||
ucs = 0x10000U + ((ucs&0x3ff)<<10) + (ucs2&0x3ff);
|
ucs = 0x10000U + ((ucs&0x3ff)<<10) + (ucs2&0x3ff);
|
||||||
// all surrogate pairs turn into 4-byte utf8
|
/* all surrogate pairs turn into 4-byte utf8 */
|
||||||
#else
|
#else
|
||||||
} else if (ucs >= 0x10000) {
|
} else if (ucs >= 0x10000) {
|
||||||
if (ucs > 0x10ffff) {
|
if (ucs > 0x10ffff) {
|
||||||
@ -551,24 +552,24 @@ unsigned fl_utf8fromwc(char* dst, unsigned dstlen,
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
J1:
|
J1:
|
||||||
#endif
|
#endif
|
||||||
// all others are 3 bytes:
|
/* all others are 3 bytes: */
|
||||||
if (count+3 >= dstlen) {dst[count] = 0; count += 3; break;}
|
if (count+3 >= dstlen) {dst[count] = 0; count += 3; break;}
|
||||||
dst[count++] = 0xe0 | (ucs >> 12);
|
dst[count++] = 0xe0 | (ucs >> 12);
|
||||||
dst[count++] = 0x80 | ((ucs >> 6) & 0x3F);
|
dst[count++] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||||
dst[count++] = 0x80 | (ucs & 0x3F);
|
dst[count++] = 0x80 | (ucs & 0x3F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we filled dst, measure the rest:
|
/* we filled dst, measure the rest: */
|
||||||
while (i < srclen) {
|
while (i < srclen) {
|
||||||
unsigned ucs = src[i++];
|
unsigned ucs = src[i++];
|
||||||
if (ucs < 0x80U) {
|
if (ucs < 0x80U) {
|
||||||
count++;
|
count++;
|
||||||
} else if (ucs < 0x800U) { // 2 bytes
|
} else if (ucs < 0x800U) { /* 2 bytes */
|
||||||
count += 2;
|
count += 2;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
} else if (ucs >= 0xd800 && ucs <= 0xdbff && i < srclen-1 &&
|
} else if (ucs >= 0xd800 && ucs <= 0xdbff && i < srclen-1 &&
|
||||||
src[i+1] >= 0xdc00 && src[i+1] <= 0xdfff) {
|
src[i+1] >= 0xdc00 && src[i+1] <= 0xdfff) {
|
||||||
// surrogate pair
|
/* surrogate pair */
|
||||||
++i;
|
++i;
|
||||||
#else
|
#else
|
||||||
} else if (ucs >= 0x10000 && ucs <= 0x10ffff) {
|
} else if (ucs >= 0x10000 && ucs <= 0x10ffff) {
|
||||||
@ -613,13 +614,13 @@ unsigned fl_utf8froma(char* dst, unsigned dstlen,
|
|||||||
if (ucs < 0x80U) {
|
if (ucs < 0x80U) {
|
||||||
dst[count++] = ucs;
|
dst[count++] = ucs;
|
||||||
if (count >= dstlen) {dst[count-1] = 0; break;}
|
if (count >= dstlen) {dst[count-1] = 0; break;}
|
||||||
} else { // 2 bytes (note that CP1252 translate could make 3 bytes!)
|
} else { /* 2 bytes (note that CP1252 translate could make 3 bytes!) */
|
||||||
if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
|
if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
|
||||||
dst[count++] = 0xc0 | (ucs >> 6);
|
dst[count++] = 0xc0 | (ucs >> 6);
|
||||||
dst[count++] = 0x80 | (ucs & 0x3F);
|
dst[count++] = 0x80 | (ucs & 0x3F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we filled dst, measure the rest:
|
/* we filled dst, measure the rest: */
|
||||||
while (p < e) {
|
while (p < e) {
|
||||||
unsigned char ucs = *(unsigned char*)p++;
|
unsigned char ucs = *(unsigned char*)p++;
|
||||||
if (ucs < 0x80U) {
|
if (ucs < 0x80U) {
|
||||||
@ -654,7 +655,7 @@ int fl_utf8locale(void) {
|
|||||||
ret = GetACP() == CP_UTF8;
|
ret = GetACP() == CP_UTF8;
|
||||||
#else
|
#else
|
||||||
char* s;
|
char* s;
|
||||||
ret = 1; // assumme UTF-8 if no locale
|
ret = 1; /* assumme UTF-8 if no locale */
|
||||||
if (((s = getenv("LC_CTYPE")) && *s) ||
|
if (((s = getenv("LC_CTYPE")) && *s) ||
|
||||||
((s = getenv("LC_ALL")) && *s) ||
|
((s = getenv("LC_ALL")) && *s) ||
|
||||||
((s = getenv("LANG")) && *s)) {
|
((s = getenv("LANG")) && *s)) {
|
||||||
@ -696,13 +697,14 @@ unsigned fl_utf8to_mb(const char* src, unsigned srclen,
|
|||||||
fl_utf8towc(src, srclen, buf, length+1);
|
fl_utf8towc(src, srclen, buf, length+1);
|
||||||
}
|
}
|
||||||
if (dstlen) {
|
if (dstlen) {
|
||||||
// apparently this does not null-terminate, even though msdn
|
/* apparently this does not null-terminate, even though msdn
|
||||||
// documentation claims it does:
|
* documentation claims it does:
|
||||||
|
*/
|
||||||
ret =
|
ret =
|
||||||
WideCharToMultiByte(GetACP(), 0, buf, length, dst, dstlen, 0, 0);
|
WideCharToMultiByte(GetACP(), 0, buf, length, dst, dstlen, 0, 0);
|
||||||
dst[ret] = 0;
|
dst[ret] = 0;
|
||||||
}
|
}
|
||||||
// if it overflows or measuring length, get the actual length:
|
/* if it overflows or measuring length, get the actual length: */
|
||||||
if (dstlen==0 || ret >= dstlen-1)
|
if (dstlen==0 || ret >= dstlen-1)
|
||||||
ret =
|
ret =
|
||||||
WideCharToMultiByte(GetACP(), 0, buf, length, 0, 0, 0, 0);
|
WideCharToMultiByte(GetACP(), 0, buf, length, 0, 0, 0, 0);
|
||||||
@ -725,10 +727,10 @@ unsigned fl_utf8to_mb(const char* src, unsigned srclen,
|
|||||||
}
|
}
|
||||||
if (buf != lbuf) free((void*)buf);
|
if (buf != lbuf) free((void*)buf);
|
||||||
if (ret >= 0) return (unsigned)ret;
|
if (ret >= 0) return (unsigned)ret;
|
||||||
// on any errors we return the UTF-8 as raw text...
|
/* on any errors we return the UTF-8 as raw text...*/
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// identity transform:
|
/* identity transform: */
|
||||||
if (srclen < dstlen) {
|
if (srclen < dstlen) {
|
||||||
memcpy(dst, src, srclen);
|
memcpy(dst, src, srclen);
|
||||||
dst[srclen] = 0;
|
dst[srclen] = 0;
|
||||||
@ -792,10 +794,10 @@ unsigned fl_utf8from_mb(char* dst, unsigned dstlen,
|
|||||||
if (buf != lbuf) free((void*)buf);
|
if (buf != lbuf) free((void*)buf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// errors in conversion return the UTF-8 unchanged
|
/* errors in conversion return the UTF-8 unchanged */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// identity transform:
|
/* identity transform: */
|
||||||
if (srclen < dstlen) {
|
if (srclen < dstlen) {
|
||||||
memcpy(dst, src, srclen);
|
memcpy(dst, src, srclen);
|
||||||
dst[srclen] = 0;
|
dst[srclen] = 0;
|
||||||
|
@ -51,13 +51,14 @@
|
|||||||
# if defined(WIN32) && !defined(__CYGWIN__)
|
# if defined(WIN32) && !defined(__CYGWIN__)
|
||||||
# define strcasecmp(s,t) _stricmp((s), (t))
|
# define strcasecmp(s,t) _stricmp((s), (t))
|
||||||
# define strncasecmp(s,t,n) _strnicmp((s), (t), (n))
|
# define strncasecmp(s,t,n) _strnicmp((s), (t), (n))
|
||||||
// Visual C++ 2005 incorrectly displays a warning about the use of POSIX APIs
|
/* Visual C++ 2005 incorrectly displays a warning about the use of POSIX APIs
|
||||||
// on Windows, which is supposed to be POSIX compliant... Some of these
|
* on Windows, which is supposed to be POSIX compliant... Some of these
|
||||||
// functions are also defined in ISO C99...
|
* functions are also defined in ISO C99...
|
||||||
|
*/
|
||||||
# ifndef __WATCOMC__
|
# ifndef __WATCOMC__
|
||||||
# define strdup _strdup
|
# define strdup _strdup
|
||||||
# define unlink _unlink
|
# define unlink _unlink
|
||||||
# endif // !__WATCOMC__
|
# endif /* !__WATCOMC__ */
|
||||||
# elif defined(__EMX__)
|
# elif defined(__EMX__)
|
||||||
# define strcasecmp(s,t) stricmp((s), (t))
|
# define strcasecmp(s,t) stricmp((s), (t))
|
||||||
# define strncasecmp(s,t,n) strnicmp((s), (t), (n))
|
# define strncasecmp(s,t,n) strnicmp((s), (t), (n))
|
||||||
|
@ -114,7 +114,7 @@ void glutStrokeString(void* fontID, const unsigned char *string) {
|
|||||||
* A newline will simply translate the next character's insertion
|
* A newline will simply translate the next character's insertion
|
||||||
* point back to the start of the line and down one line.
|
* point back to the start of the line and down one line.
|
||||||
*/
|
*/
|
||||||
#if !defined(WIN32) || defined(CYGWIN)
|
#if !defined(WIN32) && !defined(sgi) || defined(CYGWIN)
|
||||||
#warning FIXME This needs to be UTF aware now
|
#warning FIXME This needs to be UTF aware now
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
// "$Id: $"
|
/* "$Id: $"
|
||||||
//
|
*
|
||||||
// Author: Jean-Marc Lienher ( http://oksid.ch )
|
* Author: Jean-Marc Lienher ( http://oksid.ch )
|
||||||
// Copyright 2000-2003 by O'ksi'D.
|
* Copyright 2000-2003 by O'ksi'D.
|
||||||
//
|
*
|
||||||
// This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
// License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
// version 2 of the License, or (at your option) any later version.
|
* version 2 of the License, or (at your option) any later version.
|
||||||
//
|
*
|
||||||
// This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// Library General Public License for more details.
|
* Library General Public License for more details.
|
||||||
//
|
*
|
||||||
// You should have received a copy of the GNU Library General Public
|
* You should have received a copy of the GNU Library General Public
|
||||||
// License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
// USA.
|
* USA.
|
||||||
//
|
*
|
||||||
// Please report all bugs and problems on the following page:
|
* Please report all bugs and problems on the following page:
|
||||||
//
|
*
|
||||||
// http://www.fltk.org/str.php
|
* http://www.fltk.org/str.php
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is required on all platforms for utf8 support
|
* This file is required on all platforms for utf8 support
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
// "$Id: $"
|
/* "$Id: $"
|
||||||
//
|
*
|
||||||
// Author: Jean-Marc Lienher ( http://oksid.ch )
|
* Author: Jean-Marc Lienher ( http://oksid.ch )
|
||||||
// Copyright 2000-2003 by O'ksi'D.
|
* Copyright 2000-2003 by O'ksi'D.
|
||||||
//
|
*
|
||||||
// This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
// License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
// version 2 of the License, or (at your option) any later version.
|
* version 2 of the License, or (at your option) any later version.
|
||||||
//
|
*
|
||||||
// This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// Library General Public License for more details.
|
* Library General Public License for more details.
|
||||||
//
|
*
|
||||||
// You should have received a copy of the GNU Library General Public
|
* You should have received a copy of the GNU Library General Public
|
||||||
// License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
// USA.
|
* USA.
|
||||||
//
|
*
|
||||||
// Please report all bugs and problems on the following page:
|
* Please report all bugs and problems on the following page:
|
||||||
//
|
*
|
||||||
// http://www.fltk.org/str.php
|
* http://www.fltk.org/str.php
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is required on all platforms for utf8 support
|
* This file is required on all platforms for utf8 support
|
||||||
|
@ -1,26 +1,27 @@
|
|||||||
// "$Id: $"
|
/* "$Id: $"
|
||||||
//
|
*
|
||||||
// Author: Jean-Marc Lienher ( http://oksid.ch )
|
* Author: Jean-Marc Lienher ( http://oksid.ch )
|
||||||
// Copyright 2000-2003 by O'ksi'D.
|
* Copyright 2000-2003 by O'ksi'D.
|
||||||
//
|
*
|
||||||
// This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
// License as published by the Free Software Foundation; either
|
* License as published by the Free Software Foundation; either
|
||||||
// version 2 of the License, or (at your option) any later version.
|
* version 2 of the License, or (at your option) any later version.
|
||||||
//
|
*
|
||||||
// This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
// Library General Public License for more details.
|
* Library General Public License for more details.
|
||||||
//
|
*
|
||||||
// You should have received a copy of the GNU Library General Public
|
* You should have received a copy of the GNU Library General Public
|
||||||
// License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
// USA.
|
* USA.
|
||||||
//
|
*
|
||||||
// Please report all bugs and problems on the following page:
|
* Please report all bugs and problems on the following page:
|
||||||
//
|
*
|
||||||
// http://www.fltk.org/str.php
|
* http://www.fltk.org/str.php
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is required on all platforms for utf8 support
|
* This file is required on all platforms for utf8 support
|
||||||
|
@ -36,7 +36,7 @@ long XKeysymToUcs(KeySym keysym)
|
|||||||
return (long) KeySymToUcs4(keysym);
|
return (long) KeySymToUcs4(keysym);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // X11 only
|
#endif /* X11 only */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End of "$Id$".
|
* End of "$Id$".
|
||||||
|
@ -63,16 +63,16 @@ typedef struct {
|
|||||||
#include "headers/dingbats_.h"
|
#include "headers/dingbats_.h"
|
||||||
|
|
||||||
/*************** conv_gen.c ************/
|
/*************** conv_gen.c ************/
|
||||||
//const
|
/*const*/
|
||||||
int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
||||||
{
|
{
|
||||||
switch(enc) {
|
switch(enc) {
|
||||||
case 0: //iso10646-1
|
case 0: /* iso10646-1 */
|
||||||
s[0] = (char) ((ucs & 0xFF00) >> 8);
|
s[0] = (char) ((ucs & 0xFF00) >> 8);
|
||||||
s[1] = (char) (ucs & 0xFF);
|
s[1] = (char) (ucs & 0xFF);
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case 1: //iso8859-1
|
case 1: /* iso8859-1 */
|
||||||
if (ucs <= 0x00FF) {
|
if (ucs <= 0x00FF) {
|
||||||
if (ucs >= 0x0001) {
|
if (ucs >= 0x0001) {
|
||||||
s[0] = 0;
|
s[0] = 0;
|
||||||
@ -81,7 +81,7 @@ int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: //iso8859-2
|
case 2: /* iso8859-2 */
|
||||||
if (ucs <= 0x00a0) {
|
if (ucs <= 0x00a0) {
|
||||||
s[0] = 0;
|
s[0] = 0;
|
||||||
s[1] = (char) ucs;
|
s[1] = (char) ucs;
|
||||||
@ -100,102 +100,102 @@ int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: //iso8859-3
|
case 3: /* iso8859-3 */
|
||||||
if (iso8859_3_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_3_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4: //iso8859-4
|
case 4: /* iso8859-4 */
|
||||||
if (iso8859_4_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_4_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5: //iso8859-5
|
case 5: /* iso8859-5 */
|
||||||
if (iso8859_5_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_5_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 6: //iso8859-6
|
case 6: /* iso8859-6 */
|
||||||
if (iso8859_6_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_6_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7: //iso8859-7
|
case 7: /* iso8859-7 */
|
||||||
if (iso8859_7_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_7_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 7;
|
return 7;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8: //iso8859-8
|
case 8: /* iso8859-8 */
|
||||||
if (iso8859_8_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_8_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 9: //iso8859-9
|
case 9: /* iso8859-9 */
|
||||||
if (iso8859_9_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_9_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 9;
|
return 9;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 10: //iso8859-10
|
case 10: /* iso8859-10 */
|
||||||
if (iso8859_10_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_10_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 25: //iso8859-11
|
case 25: /* iso8859-11 */
|
||||||
if (iso8859_11_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_11_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 25;
|
return 25;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 11: //iso8859-13
|
case 11: /* iso8859-13 */
|
||||||
if (iso8859_13_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_13_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 11;
|
return 11;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 12: //iso8859-14
|
case 12: /* iso8859-14 */
|
||||||
if (iso8859_14_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_14_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 13: //iso8859-15
|
case 13: /* iso8859-15 */
|
||||||
if (iso8859_15_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (iso8859_15_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 13;
|
return 13;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 14: //koi8-r
|
case 14: /* koi8-r */
|
||||||
if (koi8_r_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (koi8_r_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 14;
|
return 14;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 15: //big5
|
case 15: /* big5 */
|
||||||
if (big5_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (big5_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16: //ksc5601.1987-0
|
case 16: /* ksc5601.1987-0 */
|
||||||
if (ksc5601_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (ksc5601_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 17: //gb2312.1980-0
|
case 17: /* gb2312.1980-0 */
|
||||||
if (gb2312_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (gb2312_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 17;
|
return 17;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 18: //jisx0201.1976-0
|
case 18: /* jisx0201.1976-0 */
|
||||||
if (jisx0201_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (jisx0201_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 18;
|
return 18;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 19: //jisx0208.1983-0
|
case 19: /* jisx0208.1983-0 */
|
||||||
if (jisx0208_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (jisx0208_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 19;
|
return 19;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 20: //jisx0212.1990-0
|
case 20: /* jisx0212.1990-0 */
|
||||||
if (jisx0212_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (jisx0212_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 21: //symbol
|
case 21: /* symbol */
|
||||||
if (ucs <= 0x00F7) {
|
if (ucs <= 0x00F7) {
|
||||||
if (ucs >= 0x0020) {
|
if (ucs >= 0x0020) {
|
||||||
s[0] = 0;
|
s[0] = 0;
|
||||||
@ -246,7 +246,7 @@ int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 22: //dingbats
|
case 22: /* dingbats */
|
||||||
if (ucs <= 0x00A0) {
|
if (ucs <= 0x00A0) {
|
||||||
if (ucs >= 0x0020) {
|
if (ucs >= 0x0020) {
|
||||||
s[0] = 0;
|
s[0] = 0;
|
||||||
@ -285,12 +285,12 @@ int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 23: //koi8-u
|
case 23: /* koi8-u */
|
||||||
if (koi8_u_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (koi8_u_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 23;
|
return 23;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 24: //microsoft-cp1251
|
case 24: /* microsoft-cp1251 */
|
||||||
if (cp1251_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
if (cp1251_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
|
||||||
return 24;
|
return 24;
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
|||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
//const
|
/*const*/
|
||||||
int encoding_number(const char *enc)
|
int encoding_number(const char *enc)
|
||||||
{
|
{
|
||||||
if (!enc || !strncmp(enc, "iso10646-1", 10)) {
|
if (!enc || !strncmp(enc, "iso10646-1", 10)) {
|
||||||
|
@ -367,7 +367,7 @@ XConvertEucToUtf8(
|
|||||||
|
|
||||||
if (strstr(locale, "ja")) {
|
if (strstr(locale, "ja")) {
|
||||||
return XConvertEucJpToUtf8(buffer_return, len);
|
return XConvertEucJpToUtf8(buffer_return, len);
|
||||||
} else if (strstr(locale, "Big5") || strstr(locale, "big5")) { // BIG5
|
} else if (strstr(locale, "Big5") || strstr(locale, "big5")) { /* BIG5 */
|
||||||
return XConvertBig5ToUtf8(buffer_return, len);
|
return XConvertBig5ToUtf8(buffer_return, len);
|
||||||
} else if (strstr(locale, "zh") || strstr(locale, "chinese-")) {
|
} else if (strstr(locale, "zh") || strstr(locale, "chinese-")) {
|
||||||
if (strstr(locale, "TW") || strstr(locale, "chinese-t")) {
|
if (strstr(locale, "TW") || strstr(locale, "chinese-t")) {
|
||||||
@ -432,7 +432,7 @@ XUtf8LookupString(
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // X11 only
|
#endif /* X11 only */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End of "$Id$".
|
* End of "$Id$".
|
||||||
|
@ -240,7 +240,7 @@ XFastConvertUtf8ToUcs(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // X11 only
|
#endif /* X11 only */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End of "$Id: $".
|
* End of "$Id: $".
|
||||||
|
@ -915,7 +915,7 @@ XFreeUtf8FontStruct(
|
|||||||
free(font_set);
|
free(font_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // X11 only
|
#endif /* X11 only */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End of "$Id: $".
|
* End of "$Id: $".
|
||||||
|
Loading…
Reference in New Issue
Block a user