summaryrefslogtreecommitdiff
path: root/source3/lib/charcnv.c
diff options
context:
space:
mode:
authorJohn Terpstra <jht@samba.org>2003-06-15 06:07:53 +0000
committerJohn Terpstra <jht@samba.org>2003-06-15 06:07:53 +0000
commit489956c82391d7559bb097b112957e6a7d91934c (patch)
treeac9dd17331cdf513de4fd98fcc165536b658963d /source3/lib/charcnv.c
parent5d4937c2b6e5b01fd13bc197224459ab690897e9 (diff)
downloadsamba-489956c82391d7559bb097b112957e6a7d91934c.tar.gz
samba-489956c82391d7559bb097b112957e6a7d91934c.tar.bz2
samba-489956c82391d7559bb097b112957e6a7d91934c.zip
Patch from vorlon@debian.org, see bugzilal #122
Samba should preferentially use the locale information from the native system, and only fall back on 'display charset' if this is unavailable or unsupported. (This used to be commit 1e445fb4220cdf4700dd9d1850a42746a1065c5a)
Diffstat (limited to 'source3/lib/charcnv.c')
-rw-r--r--source3/lib/charcnv.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 708ef343e1..b37f468134 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -90,10 +90,28 @@ void init_iconv(void)
if (!conv_handles[CH_UCS2][CH_UNIX])
conv_handles[CH_UCS2][CH_UNIX] = smb_iconv_open("ASCII", "UCS-2LE");
+#ifdef HAVE_SETLOCALE
+ setlocale(LC_ALL, "");
+#endif
+
for (c1=0;c1<NUM_CHARSETS;c1++) {
for (c2=0;c2<NUM_CHARSETS;c2++) {
const char *n1 = charset_name((charset_t)c1);
const char *n2 = charset_name((charset_t)c2);
+#ifdef HAVE_NL_LANGINFO
+ const char *ln = nl_langinfo(CODESET);
+
+ if (c1==CH_DISPLAY && conv_handles[c1][c2] &&
+ strcmp(ln, conv_handles[c1][c2]->from_name) == 0 &&
+ strcmp(n2, conv_handles[c1][c2]->to_name) == 0)
+ continue;
+
+ if (c2==CH_DISPLAY && conv_handles[c1][c2] &&
+ strcmp(n1, conv_handles[c1][c2]->from_name) == 0 &&
+ strcmp(ln, conv_handles[c1][c2]->to_name) == 0)
+ continue;
+
+#endif
if (conv_handles[c1][c2] &&
strcmp(n1, conv_handles[c1][c2]->from_name) == 0 &&
strcmp(n2, conv_handles[c1][c2]->to_name) == 0)
@@ -104,6 +122,25 @@ void init_iconv(void)
if (conv_handles[c1][c2])
smb_iconv_close(conv_handles[c1][c2]);
+#ifdef HAVE_NL_LANGINFO
+ if (c1==CH_DISPLAY && c2==CH_DISPLAY) {
+ conv_handles[c1][c2] = smb_iconv_open(ln,ln);
+ if (conv_handles[c1][c2] != (smb_iconv_t)-1) {
+ continue;
+ }
+ } else if (c1==CH_DISPLAY) {
+ conv_handles[c1][c2] = smb_iconv_open(n2,ln);
+ if (conv_handles[c1][c2] != (smb_iconv_t)-1) {
+ continue;
+ }
+ } else if (c2==CH_DISPLAY) {
+ conv_handles[c1][c2] = smb_iconv_open(ln,n1);
+ if (conv_handles[c1][c2] != (smb_iconv_t)-1) {
+ continue;
+ }
+ }
+ /* Fall back to the configured charset. */
+#endif
conv_handles[c1][c2] = smb_iconv_open(n2,n1);
if (conv_handles[c1][c2] == (smb_iconv_t)-1) {
DEBUG(0,("Conversion from %s to %s not supported\n",