STR #2155: fixed using sparkaround's patch conditional to use of configure --enable-cp936

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7902 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2010-11-28 18:55:50 +00:00
parent dcfdf8be20
commit f4fc4241b7
7 changed files with 7335 additions and 3 deletions

View File

@ -200,6 +200,12 @@ else
DEBUGFLAG=""
fi
AC_ARG_ENABLE(cp936, [ --enable-cp936 turn on CP936 [default=no]])
if test x$enable_cp936 = xyes; then
CFLAGS="$CFLAGS -DCP936"
fi
AC_ARG_ENABLE(gl, [ --enable-gl turn on OpenGL support [default=yes]])
AC_ARG_ENABLE(shared, [ --enable-shared turn on shared libraries [default=no]])

View File

@ -21,6 +21,7 @@ iso8859-15
koi8-r
koi8-u
big5-0
gbk
gb2312.1980-0
jisx0201.1976-0
jisx0208.1983-0

View File

@ -3,7 +3,7 @@ $XFree86: xc/lib/X11/lcUniConv/README,v 1.3 2003/10/24 15:34:01 tsi Exp $
The files in this directory are taken from the libiconv-1.1 package.
The *.h files were generated from tables (mostly from ftp.unicode.org) using
the programs '8bit_tab_to_h.c' and 'cjk_tab_to_h.c'. On some of them, further
the programs '8bit_tab_to_h.c', 'cjk_tab_to_h.c' and 'gbk_tab_to_h.c'. On some of them, further
optimizations were applied by hand.
If you find a bug in these files, instead of modifying them in XFree86

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@ typedef struct {
} Summary16;
#include "lcUniConv/cp936ext.h"
#include "lcUniConv/big5.h"
#include "lcUniConv/gb2312.h"
#include "lcUniConv/iso8859_10.h"
@ -295,6 +296,11 @@ int ucs2fontmap(char *s, unsigned int ucs, int enc) {
return 24;
}
break;
case 26: /* gbk/cp936ext */
if (cp936ext_wctomb(NULL, (unsigned char*)s, ucs, 2) > 0) {
return 26;
}
break;
default:
break;
};
@ -363,6 +369,8 @@ int encoding_number(const char *enc) {
return 24;
} else if (!strcmp(enc, "iso8859-11")) {
return 25;
} else if (!strcmp(enc, "gbk-0") || !strcmp(enc, "cp936") || !strcmp(enc, "gbk")) {
return 26;
};
return -1;
};

View File

@ -54,6 +54,7 @@ typedef struct {
#include "lcUniConv/big5.h"
#include "lcUniConv/gb2312.h"
#include "lcUniConv/cp936ext.h"
#include "lcUniConv/jisx0201.h"
#include "lcUniConv/jisx0208.h"
#include "lcUniConv/jisx0212.h"
@ -190,6 +191,43 @@ XConvertBig5ToUtf8(char* buffer_return, int len) {
return l;
}
int
XConvertCp936extToUtf8(char* buffer_return, int len)
{
int i = 0, l = 0;
char *buf;
if (len < 1) return 0;
buf = (char*) malloc((unsigned)len);
memcpy(buf, buffer_return, (unsigned)len);
if (len == 1) {
l += XConvertUcsToUtf8((unsigned int)buf[i], buffer_return + l);
}
while (i + 1 < len) {
unsigned int ucs;
unsigned char b[2];
b[0] = (unsigned char) buf[i];
b[1] = (unsigned char) buf[i + 1];
if (cp936ext_mbtowc(NULL, &ucs, b, 2) == 2) {
i += 2;
} else {
if ( b[0] < 0x80) {
ucs = b[0];
}else{
ucs = '?';
}
i++;
}
l += XConvertUcsToUtf8(ucs, buffer_return + l);
}
if(i + 1 == len) {
l += XConvertUcsToUtf8((unsigned int)buf[i], buffer_return + l);
}
free(buf);
return l;
}
int
XConvertGb2312ToUtf8(char* buffer_return, int len) {
int i = 0, l = 0;
@ -207,7 +245,10 @@ XConvertGb2312ToUtf8(char* buffer_return, int len) {
unsigned char b[2];
b[0] = (unsigned char) buf[i];
b[1] = (unsigned char) buf[i + 1];
if (gb2312_mbtowc(NULL, &ucs, b, 2) == 2) {
if ( b[0] < 0x80 ) {
ucs = b[0];
i++;
} else if (gb2312_mbtowc(NULL, &ucs, b, 2) == 2) {
i += 2;
} else {
ucs = '?';
@ -215,6 +256,9 @@ XConvertGb2312ToUtf8(char* buffer_return, int len) {
}
l += XConvertUcsToUtf8(ucs, buffer_return + l);
}
if (i + 1 == len) {
l += XConvertUcsToUtf8((unsigned int)buf[i], buffer_return + l);
}
free(buf);
return l;
}
@ -337,7 +381,8 @@ XConvertEucToUtf8(const char* locale,
int len,
int bytes_buffer) {
if (!locale/* || strstr(locale, "UTF") || strstr(locale, "utf")*/) {
//if (!locale/* || strstr(locale, "UTF") || strstr(locale, "utf")*/) {
if (!locale || strstr(locale, "UTF") || strstr(locale, "utf")) {
return len;
}
@ -345,6 +390,8 @@ XConvertEucToUtf8(const char* locale,
return XConvertEucJpToUtf8(buffer_return, len);
} else if (strstr(locale, "Big5") || strstr(locale, "big5")) { /* BIG5 */
return XConvertBig5ToUtf8(buffer_return, len);
} else if (strstr(locale, "GBK") || strstr(locale, "gbk")) {
return XConvertCp936extToUtf8(buffer_return, len);
} else if (strstr(locale, "zh") || strstr(locale, "chinese-")) {
if (strstr(locale, "TW") || strstr(locale, "chinese-t")) {
if (strstr(locale, "EUC") || strstr(locale, "euc") || strstr(locale, "chinese-t")) {