r3063: our default dos charset is CP850, but some systems don't have that, so
authorAndrew Tridgell <tridge@samba.org>
Tue, 19 Oct 2004 10:15:34 +0000 (10:15 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:01:55 +0000 (13:01 -0500)
as a special case, automatically fall back to ASCII if its not found.

source/lib/charcnv.c

index 40e68df98490c67091b8d74074b75d80fb88afd9..3c27d596647e6719503f6c07b53cd5a8d2f1a9f2 100644 (file)
@@ -98,6 +98,20 @@ static smb_iconv_t get_conv_handle(charset_t from, charset_t to)
        n2 = charset_name(to);
 
        conv_handles[from][to] = smb_iconv_open(n2,n1);
+       
+       if (conv_handles[from][to] == (smb_iconv_t)-1) {
+               if ((from == CH_DOS || to == CH_DOS) &&
+                   strcasecmp(charset_name(CH_DOS), "ASCII") != 0) {
+                       DEBUG(0,("dos charset '%s' unavailable - using ASCII\n",
+                                charset_name(CH_DOS)));
+                       lp_set_cmdline("dos charset", "ASCII");
+
+                       n1 = charset_name(from);
+                       n2 = charset_name(to);
+                       
+                       conv_handles[from][to] = smb_iconv_open(n2,n1);
+               }
+       }
 
        return conv_handles[from][to];
 }