[mapserver-commits] r8475 - sandbox/hobu/ISC_5.4/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Jan 28 23:28:31 EST 2009
Author: hobu
Date: 2009-01-28 23:28:31 -0500 (Wed, 28 Jan 2009)
New Revision: 8475
Modified:
sandbox/hobu/ISC_5.4/mapserver/mapstring.c
Log:
port r6917
Modified: sandbox/hobu/ISC_5.4/mapserver/mapstring.c
===================================================================
--- sandbox/hobu/ISC_5.4/mapserver/mapstring.c 2009-01-29 02:58:22 UTC (rev 8474)
+++ sandbox/hobu/ISC_5.4/mapserver/mapstring.c 2009-01-29 04:28:31 UTC (rev 8475)
@@ -1452,8 +1452,10 @@
if(fribidi_parse_charset ((char*)encoding))
return msGetFriBidiEncodedString(string, encoding);
#endif
- len = strlen(string);
-
+
+ //len = strlen(string);
+ len = _ISC_msGetLength(string, encoding);
+
if (len == 0 || (encoding && strcasecmp(encoding, "UTF-8")==0))
return strdup(string); /* Nothing to do: string already in UTF-8 */
@@ -1876,3 +1878,55 @@
/*no newline found in text*/
return strdup(text);
}
+
+const char *_ISC_2ByteFizedWidthFormats[] = { "UTF-16", "UTF-16LE", "UTF-16BE", "UCS-2", "UCS-2LE", "UCS-2BE", "UCS-2-INTERNAL", NULL };
+
+size_t _ISC_msGetLength(const char *string, const char *encoding)
+{
+ char *enc;
+ int n, found;
+
+ enc = strdup(encoding);
+ n = 0;
+
+ /* convert to uppercase and trim trailing junk */
+ while (enc[n] != '\0')
+ {
+ char a = enc[n];
+ if (a == ' ' || a == '/')
+ {
+ enc[n] = '\0';
+ break;
+ }
+ else if (a >= 'a' && a <= 'z')
+ {
+ a -= 32;
+ enc[n] = a;
+ }
+ n++;
+ }
+
+ /* look for matching 2 byte format */
+ found = n = 0;
+ for (; _ISC_2ByteFizedWidthFormats[n] != NULL && !found; n++)
+ {
+ if (!strcmp(enc, _ISC_2ByteFizedWidthFormats[n]))
+ {
+ found = 1;
+ }
+ }
+
+ /* free the result of the strdup call */
+ msFree(enc);
+
+ if (found)
+ {
+ /* look for 2 byte null terminator */
+ unsigned short *wstring = (unsigned short *)string;
+ n = 0;
+ while (wstring[n] != 0) n++;
+ return (size_t)(2 * (n - 1));
+ }
+
+ return strlen(string);
+}
More information about the mapserver-commits
mailing list