mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
Use s2utbl for sjis2utf
This commit is contained in:
@@ -210,9 +210,6 @@
|
||||
/* Define this if you have libXxf86vm installed */
|
||||
#undef HAVE_XF86VMODE
|
||||
|
||||
/* Define as const if the declaration of iconv() needs const. */
|
||||
#undef ICONV_CONST
|
||||
|
||||
/* joystick device */
|
||||
#undef JOY_DEVICE
|
||||
|
||||
|
||||
@@ -4335,11 +4335,11 @@ main ()
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: \"yes\"" >&5
|
||||
$as_echo "\"yes\"" >&6; };is_emscripten=yes
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; };is_emscripten=yes
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: \"no\"" >&5
|
||||
$as_echo "\"no\"" >&6; };is_emscripten=no
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; };is_emscripten=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
|
||||
@@ -15495,162 +15495,6 @@ fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
am_save_CPPFLAGS="$CPPFLAGS"
|
||||
|
||||
for element in $INCICONV; do
|
||||
haveit=
|
||||
for x in $CPPFLAGS; do
|
||||
|
||||
acl_save_prefix="$prefix"
|
||||
prefix="$acl_final_prefix"
|
||||
acl_save_exec_prefix="$exec_prefix"
|
||||
exec_prefix="$acl_final_exec_prefix"
|
||||
eval x=\"$x\"
|
||||
exec_prefix="$acl_save_exec_prefix"
|
||||
prefix="$acl_save_prefix"
|
||||
|
||||
if test "X$x" = "X$element"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
|
||||
$as_echo_n "checking for iconv... " >&6; }
|
||||
if ${am_cv_func_iconv+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
am_cv_func_iconv="no, consider installing GNU libiconv"
|
||||
am_cv_lib_iconv=no
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <stdlib.h>
|
||||
#include <iconv.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
iconv_t cd = iconv_open("","");
|
||||
iconv(cd,NULL,NULL,NULL,NULL);
|
||||
iconv_close(cd);
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
am_cv_func_iconv=yes
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
if test "$am_cv_func_iconv" != yes; then
|
||||
am_save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $LIBICONV"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <stdlib.h>
|
||||
#include <iconv.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
iconv_t cd = iconv_open("","");
|
||||
iconv(cd,NULL,NULL,NULL,NULL);
|
||||
iconv_close(cd);
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
am_cv_lib_iconv=yes
|
||||
am_cv_func_iconv=yes
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LIBS="$am_save_LIBS"
|
||||
fi
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5
|
||||
$as_echo "$am_cv_func_iconv" >&6; }
|
||||
if test "$am_cv_func_iconv" = yes; then
|
||||
|
||||
$as_echo "#define HAVE_ICONV 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
if test "$am_cv_lib_iconv" = yes; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5
|
||||
$as_echo_n "checking how to link with libiconv... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5
|
||||
$as_echo "$LIBICONV" >&6; }
|
||||
else
|
||||
CPPFLAGS="$am_save_CPPFLAGS"
|
||||
LIBICONV=
|
||||
LTLIBICONV=
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if test "$am_cv_func_iconv" = yes; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv declaration" >&5
|
||||
$as_echo_n "checking for iconv declaration... " >&6; }
|
||||
if ${am_cv_proto_iconv+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <iconv.h>
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
|
||||
#else
|
||||
size_t iconv();
|
||||
#endif
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
am_cv_proto_iconv_arg1=""
|
||||
else
|
||||
am_cv_proto_iconv_arg1="const"
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
|
||||
fi
|
||||
|
||||
am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_t:-
|
||||
}$am_cv_proto_iconv" >&5
|
||||
$as_echo "${ac_t:-
|
||||
}$am_cv_proto_iconv" >&6; }
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define ICONV_CONST $am_cv_proto_iconv_arg1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# Check whether --enable-gtk was given.
|
||||
if test "${enable_gtk+set}" = set; then :
|
||||
enableval=$enable_gtk;
|
||||
|
||||
@@ -140,11 +140,6 @@ dnl [ --enable-pkg-config Enable pkg-config for check glib|gtk [defaul
|
||||
dnl [enable_pkgc=yes])
|
||||
dnl fi
|
||||
|
||||
dnl
|
||||
dnl check iconv
|
||||
dnl
|
||||
AM_ICONV
|
||||
|
||||
dnl
|
||||
dnl check for gtk
|
||||
dnl
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>xsystem35 for web</title>
|
||||
<title>鬼畜王 on Web</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/spectre.css/0.2.10/spectre.min.css">
|
||||
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
|
||||
@@ -80,6 +80,11 @@ namespace xsystem35 {
|
||||
}
|
||||
}
|
||||
Module.print = Module.printErr = console.log.bind(console);
|
||||
Module.setWindowTitle = (title) => {
|
||||
let colon = title.indexOf(':');
|
||||
if (colon !== -1)
|
||||
$('.navbar-brand').textContent = title.slice(colon + 1);
|
||||
};
|
||||
Module.canvas = document.getElementById('canvas');
|
||||
Module.noInitialRun = true;
|
||||
Module.setStatus = this.setStatus.bind(this);
|
||||
|
||||
+3
-2
@@ -53,10 +53,11 @@ declare namespace Module {
|
||||
|
||||
// Undocumented methods / attributes
|
||||
let canvas: HTMLElement;
|
||||
function setStatus(status: string): void;
|
||||
function monitorRunDependencies(left: number): void;
|
||||
function callMain(args: string[]): void;
|
||||
function getMemory(size: number): number;
|
||||
function monitorRunDependencies(left: number): void;
|
||||
function setStatus(status: string): void;
|
||||
function setWindowTitle(title: string): void;
|
||||
}
|
||||
|
||||
declare namespace FS {
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
#include "system.h"
|
||||
#include "font.h"
|
||||
#include "ags.h"
|
||||
#include "s2utbl.h"
|
||||
|
||||
extern int cp932tosjis0213(int code);
|
||||
extern unsigned short *s2u[];
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
|
||||
+33
-33
@@ -28,48 +28,48 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_ICONV
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
|
||||
#include "portab.h"
|
||||
#include "utfsjis.h"
|
||||
|
||||
static char* convert(char* src, const char* tocode, const char* fromcode, int size_multiplier) {
|
||||
#ifdef HAVE_ICONV
|
||||
iconv_t cd = iconv_open(tocode, fromcode);
|
||||
if (cd == (iconv_t)-1)
|
||||
return NULL;
|
||||
|
||||
size_t srclen = strlen(src);
|
||||
size_t dstlen = srclen * size_multiplier + 1;
|
||||
char* dst = malloc(dstlen);
|
||||
char *srcp = src, *dstp = dst;
|
||||
if (iconv(cd, &srcp, &srclen, &dstp, &dstlen) == (size_t)-1 || !dstlen) {
|
||||
free(dst);
|
||||
iconv_close(cd);
|
||||
return NULL;
|
||||
}
|
||||
*dstp = '\0';
|
||||
iconv_close(cd);
|
||||
return dst;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
#include "s2utbl.h"
|
||||
|
||||
BYTE *sjis2utf(BYTE *src) {
|
||||
char* dst = convert(src, "utf-8", "shift-jis", 3);
|
||||
if (!dst)
|
||||
dst = strdup(src);
|
||||
BYTE* dst = malloc(strlen(src) * 3 + 1);
|
||||
BYTE* dstp = dst;
|
||||
|
||||
while (*src) {
|
||||
if (*src <= 0x7f) {
|
||||
*dstp++ = *src++;
|
||||
continue;
|
||||
}
|
||||
|
||||
int c;
|
||||
if (*src >= 0xa0 && *src <= 0xdf) {
|
||||
c = 0xff60 + *src - 0xa0;
|
||||
src++;
|
||||
} else {
|
||||
c = s2u[*src - 0x80][*(src+1) - 0x40];
|
||||
src += 2;
|
||||
}
|
||||
|
||||
if (c <= 0x7f) {
|
||||
*dstp++ = c;
|
||||
} else if (c <= 0x7ff) {
|
||||
*dstp++ = 0xc0 | c >> 6;
|
||||
*dstp++ = 0x80 | (c & 0x3f);
|
||||
} else {
|
||||
*dstp++ = 0xe0 | c >> 12;
|
||||
*dstp++ = 0x80 | (c >> 6 & 0x3f);
|
||||
*dstp++ = 0x80 | (c & 0x3f);
|
||||
}
|
||||
}
|
||||
*dstp = '\0';
|
||||
return dst;
|
||||
}
|
||||
|
||||
BYTE *utf2sjis(BYTE *src) {
|
||||
char* dst = convert(src, "shift-jis", "utf-8", 1);
|
||||
if (!dst)
|
||||
dst = strdup(src);
|
||||
return dst;
|
||||
printf("%s not implemented\n", __func__);
|
||||
return strdup(src);
|
||||
}
|
||||
|
||||
/* src 内に半角カナもしくはASCII文字があるかどうか */
|
||||
|
||||
Reference in New Issue
Block a user