summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-01 05:19:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:28 -0500
commita08808d62b455addad00d6c7ab42d12bc967cea5 (patch)
treec7adfe3234898143f6bc64382e62e010797d0cc9
parent31c1c7846f6b6e5848bc39a28a65118bfa98e35d (diff)
downloadsamba-a08808d62b455addad00d6c7ab42d12bc967cea5.tar.gz
samba-a08808d62b455addad00d6c7ab42d12bc967cea5.tar.bz2
samba-a08808d62b455addad00d6c7ab42d12bc967cea5.zip
r2164: put the latest "accept either form" utf-16 iconv code in samba4
(This used to be commit 62a0cfd865d6ad4c05e2461dbf0b81988683a219)
-rw-r--r--source4/lib/iconv.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source4/lib/iconv.c b/source4/lib/iconv.c
index 9f6526faa5..039dac2424 100644
--- a/source4/lib/iconv.c
+++ b/source4/lib/iconv.c
@@ -161,6 +161,12 @@ size_t smb_iconv(smb_iconv_t cd,
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 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
#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 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
#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;