5 <firstname>TAKAHASHI</firstname><surname>Motonobu</surname>
7 <address><email>monyo@home.monyo.com</email></address>
10 <pubdate>25 March 2003</pubdate>
13 <title>Unicode/Charsets</title>
16 <title>What are charsets and unicode?</title>
19 Computers communicate in numbers. In texts, each number will be
20 translated to a corresponding letter. The meaning that will be assigned
21 to a certain number depends on the <emphasis>character set(charset)
22 </emphasis> that is used.
23 A charset can be seen as a table that is used to translate numbers to
24 letters. Not all computers use the same charset (there are charsets
25 with German umlauts, Japanese characters, etc). Usually a charset contains
26 256 characters, which means that storing a character with it takes
27 exactly one byte. </para>
30 There are also charsets that support even more characters,
31 but those need twice(or even more) as much storage space. These
32 charsets can contain <command>256 * 256 = 65536</command> characters, which
33 is more then all possible characters one could think of. They are called
34 multibyte charsets (because they use more then one byte to
39 A standardised multibyte charset is unicode, info is available at
40 <ulink url="http://www.unicode.org/">www.unicode.org</ulink>.
41 A big advantage of using a multibyte charset is that you only need one; no
42 need to make sure two computers use the same charset when they are
46 <para>Old windows clients used to use single-byte charsets, named
47 'codepages' by microsoft. However, there is no support for
48 negotiating the charset to be used in the smb protocol. Thus, you
49 have to make sure you are using the same charset when talking to an old client.
50 Newer clients (Windows NT, 2K, XP) talk unicode over the wire.
55 <title>Samba and charsets</title>
58 As of samba 3.0, samba can (and will) talk unicode over the wire. Internally,
59 samba knows of three kinds of character sets:
64 <term><parameter>unix charset</parameter></term>
66 This is the charset used internally by your operating system.
67 The default is <constant>ASCII</constant>, which is fine for most
73 <term><parameter>display charset</parameter></term>
74 <listitem><para>This is the charset samba will use to print messages
75 on your screen. It should generally be the same as the <command>unix charset</command>.
80 <term><parameter>dos charset</parameter></term>
81 <listitem><para>This is the charset samba uses when communicating with
82 DOS and Windows 9x clients. It will talk unicode to all newer clients.
83 The default depends on the charsets you have installed on your system.
84 Run <command>testparm -v | grep "dos charset"</command> to see
85 what the default is on your system.
93 <title>Conversion from old names</title>
95 <para>Because previous samba versions did not do any charset conversion,
96 characters in filenames are usually not correct in the unix charset but only
97 for the local charset used by the DOS/Windows clients.</para>
99 <para>The following script from Steve Langasek converts all
100 filenames from CP850 to the iso8859-15 charset.</para>
103 <prompt>#</prompt><userinput>find <replaceable>/path/to/share</replaceable> -type f -exec bash -c 'CP="{}"; ISO=`echo -n "$CP" | iconv -f cp850 \
104 -t iso8859-15`; if [ "$CP" != "$ISO" ]; then mv "$CP" "$ISO"; fi' \;
110 <title>Japanese charsets</title>
112 <para>Samba doesn't work correctly with Japanese charsets yet. Here are
113 points of attention when setting it up:</para>
117 <listitem><para>You should set <parameter>mangling method =
118 hash</parameter></para></listitem>
120 <listitem><para>There are various iconv() implementations around and not
121 all of them work equally well. glibc2's iconv() has a critical problem
122 in CP932. libiconv-1.8 works with CP932 but still has some problems and
123 does not work with EUC-JP.</para></listitem>
125 <listitem><para>You should set <parameter>dos charset = CP932</parameter>, not
126 Shift_JIS, SJIS...</para></listitem>
128 <listitem><para>Currently only <parameter>unix charset = CP932</parameter>
129 will work (but still has some problems...) because of iconv() issues.
130 <parameter>unix charset = EUC-JP</parameter> doesn't work well because of
131 iconv() issues.</para></listitem>
133 <listitem><para>Currently Samba 3.0 does not support <parameter>unix charset
134 = UTF8-MAC/CAP/HEX/JIS*</parameter></para></listitem>
138 <para>More information (in Japanese) is available at: <ulink url="http://www.atmarkit.co.jp/flinux/special/samba3/samba3a.html">http://www.atmarkit.co.jp/flinux/special/samba3/samba3a.html</ulink>.</para>