[Scummvm-cvs-logs] SF.net SVN: scummvm:[48681] tools/trunk/create_sjisfnt.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Apr 17 04:50:35 CEST 2010


Revision: 48681
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48681&view=rev
Author:   lordhoto
Date:     2010-04-17 02:50:35 +0000 (Sat, 17 Apr 2010)

Log Message:
-----------
Some minor paranoia change.

Since according to http://www.unicode.org/reports/tr19/tr19-9.html, 0xFEFF
might even occur as first character in a UTF-32LE sequence, we just skip
over that one in case we ever get that.

Modified Paths:
--------------
    tools/trunk/create_sjisfnt.cpp

Modified: tools/trunk/create_sjisfnt.cpp
===================================================================
--- tools/trunk/create_sjisfnt.cpp	2010-04-17 02:40:44 UTC (rev 48680)
+++ tools/trunk/create_sjisfnt.cpp	2010-04-17 02:50:35 UTC (rev 48681)
@@ -331,10 +331,10 @@
 	inBuf[1] = sB;
 	inBuf[2] = 0;
 
-	char outBuf[2 * sizeof(uint32)];
+	char outBuf[3 * sizeof(uint32)];
 	memset(outBuf, 0, sizeof(outBuf));
 
-	size_t inBufSize = sB ? sizeof(inBuf) : sizeof(inBuf) - 1;
+	size_t inBufSize = ((fB >= 0x81 && fB <= 0x9F) || (fB >= 0xE0 && fB <= 0xEF)) ? 3 : 2;
 	size_t outBufSize = sizeof(outBuf);
 #ifdef ICONV_USES_CONST
 	const char *inBufWrap = inBuf;
@@ -346,7 +346,16 @@
 	if (iconv(confSetup, &inBufWrap, &inBufSize, &outBufWrap, &outBufSize) == (size_t)-1)
 		return (uint32)-1;
 
-	return READ_LE_UINT32(outBuf);
+	const uint32 ret = READ_LE_UINT32(outBuf);
+
+	// According to http://www.unicode.org/reports/tr19/tr19-9.html it is possible
+	// that a "zero width no-break space" is added as first character (probably
+	// to be consistent with the "byte order mark"). In case any iconv implementation
+	// does that, we just skip over that bit.
+	if (ret == 0x0000FEFF)
+		return READ_LE_UINT32(outBuf + 4);
+	else
+		return ret;
 }
 
 FT_Library ft = NULL;


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