[Scummvm-cvs-logs] SF.net SVN: scummvm:[48680] tools/trunk
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sat Apr 17 04:40:45 CEST 2010
Revision: 48680
http://scummvm.svn.sourceforge.net/scummvm/?rev=48680&view=rev
Author: lordhoto
Date: 2010-04-17 02:40:44 +0000 (Sat, 17 Apr 2010)
Log Message:
-----------
Fix UTF-32 conversion by specifically asking iconv to use LE for encoding. Minor cleanup otherwise. Also mention fix in the NEWS file.
Modified Paths:
--------------
tools/trunk/NEWS
tools/trunk/create_sjisfnt.cpp
Modified: tools/trunk/NEWS
===================================================================
--- tools/trunk/NEWS 2010-04-17 02:14:22 UTC (rev 48679)
+++ tools/trunk/NEWS 2010-04-17 02:40:44 UTC (rev 48680)
@@ -12,4 +12,5 @@
- Fix bug #2905473: "GUI Tools: cannot use lame with compress_scumm_sou"
- Patch #2982306: "set MP3 ABR bit rate in GUI Tools"
- Patch #2982090: "Tools: include unistd.h for unlink"
- - Patch #2982091: "Tools: use $(INSTALL) instead of install".
\ No newline at end of file
+ - Patch #2982091: "Tools: use $(INSTALL) instead of install".
+ - Fix endian problem in create_sjisfnt
Modified: tools/trunk/create_sjisfnt.cpp
===================================================================
--- tools/trunk/create_sjisfnt.cpp 2010-04-17 02:14:22 UTC (rev 48679)
+++ tools/trunk/create_sjisfnt.cpp 2010-04-17 02:40:44 UTC (rev 48680)
@@ -28,6 +28,7 @@
#include <iconv.h>
#include <list>
#include <assert.h>
+#include <errno.h>
#include "common/endian.h"
#include "common/file.h"
@@ -300,9 +301,9 @@
iconv_t confSetup = (iconv_t)-1;
bool initSJIStoUTF32Conversion() {
- // We initialize a SJIS to native endian UTF-32 conversion
+ // We initialize a SJIS to little endian UTF-32 conversion
// over here.
- confSetup = iconv_open("UTF-32", "SJIS");
+ confSetup = iconv_open("UTF-32LE", "SJIS");
return (confSetup != (iconv_t)-1);
}
@@ -330,10 +331,10 @@
inBuf[1] = sB;
inBuf[2] = 0;
- char outBuf[3 * sizeof(uint32)];
+ char outBuf[2 * sizeof(uint32)];
memset(outBuf, 0, sizeof(outBuf));
- size_t inBufSize = sizeof(inBuf);
+ size_t inBufSize = sB ? sizeof(inBuf) : sizeof(inBuf) - 1;
size_t outBufSize = sizeof(outBuf);
#ifdef ICONV_USES_CONST
const char *inBufWrap = inBuf;
@@ -345,16 +346,7 @@
if (iconv(confSetup, &inBufWrap, &inBufSize, &outBufWrap, &outBufSize) == (size_t)-1)
return (uint32)-1;
- uint32 ret = *(uint32 *)outBuf;
-
- // It might happen that iconv will add a "byte order mark"
- // we use that to determin the endianness.
- if (ret == 0x0000FEFF)
- ret = *(uint32 *)(outBuf + 4);
- else if (SWAP_32(ret) == 0x0000FEFF)
- ret = SWAP_32(*(uint32 *)(outBuf + 4));
-
- return ret;
+ return READ_LE_UINT32(outBuf);
}
FT_Library ft = NULL;
@@ -416,7 +408,8 @@
// It might be useful to enable that warning again to detect problems with
// iconv though. An example for such an iconv problem is the
// "FULLWIDTH APOSTROPHE", which iconv refuses to convert to UTF-32.
- //warning("Conversion error on: %.2X %.02X", fB, sB);
+ if (errno == E2BIG || errno == EINVAL)
+ warning("Conversion error on: %.2X %.02X", fB, sB);
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list