svn commit: samba r2164 - in branches/SAMBA_4_0/source/lib: .

tridge at samba.org tridge at samba.org
Wed Sep 1 05:19:01 GMT 2004


Author: tridge
Date: 2004-09-01 05:19:00 +0000 (Wed, 01 Sep 2004)
New Revision: 2164

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/lib&rev=2164&nolog=1

Log:
put the latest "accept either form" utf-16 iconv code in samba4

Modified:
   branches/SAMBA_4_0/source/lib/iconv.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/iconv.c
===================================================================
--- branches/SAMBA_4_0/source/lib/iconv.c	2004-09-01 05:17:40 UTC (rev 2163)
+++ branches/SAMBA_4_0/source/lib/iconv.c	2004-09-01 05:19:00 UTC (rev 2164)
@@ -161,6 +161,12 @@
 	return 0;
 }
 
+static BOOL is_utf16(const char *name)
+{
+	return strcasecmp(name, "UCS-2LE") == 0 ||
+		strcasecmp(name, "UTF-16LE") == 0;
+}
+
 /*
   simple iconv_open() wrapper
  */
@@ -202,13 +208,17 @@
 #ifdef HAVE_NATIVE_ICONV
 	if (!from) {
 		ret->pull = sys_iconv;
-		ret->cd_pull = iconv_open("UCS-2LE", fromcode);
+		ret->cd_pull = iconv_open("UTF-16LE", fromcode);
+		if (ret->cd_pull == (iconv_t)-1)
+			ret->cd_pull = iconv_open("UCS-2LE", fromcode);
 		if (ret->cd_pull == (iconv_t)-1) goto failed;
 	}
 
 	if (!to) {
 		ret->push = sys_iconv;
-		ret->cd_push = iconv_open(tocode, "UCS-2LE");
+		ret->cd_push = iconv_open(tocode, "UTF-16LE");
+		if (ret->cd_push == (iconv_t)-1)
+			ret->cd_push = iconv_open(tocode, "UCS-2LE");
 		if (ret->cd_push == (iconv_t)-1) goto failed;
 	}
 #else
@@ -218,23 +228,23 @@
 #endif
 
 	/* check for conversion to/from ucs2 */
-	if (strcasecmp(fromcode, "UTF-16LE") == 0 && to) {
+	if (is_utf16(fromcode) && to) {
 		ret->direct = to->push;
 		return ret;
 	}
-	if (strcasecmp(tocode, "UTF-16LE") == 0 && from) {
+	if (is_utf16(tocode) && from) {
 		ret->direct = from->pull;
 		return ret;
 	}
 
 #ifdef HAVE_NATIVE_ICONV
-	if (strcasecmp(fromcode, "UTF-16LE") == 0) {
+	if (is_utf16(fromcode)) {
 		ret->direct = sys_iconv;
 		ret->cd_direct = ret->cd_push;
 		ret->cd_push = NULL;
 		return ret;
 	}
-	if (strcasecmp(tocode, "UTF-16LE") == 0) {
+	if (is_utf16(tocode)) {
 		ret->direct = sys_iconv;
 		ret->cd_direct = ret->cd_pull;
 		ret->cd_pull = NULL;



More information about the samba-cvs mailing list