A lot of syntax updates, consistency when using certain tags and converting ASCII...
[sfrench/samba-autobuild/.git] / docs / docbook / projdoc / unicode.xml
1 <chapter id="unicode">
2 <chapterinfo>
3         &author.jelmer;
4         <author>
5                 <firstname>TAKAHASHI</firstname><surname>Motonobu</surname>
6                 <affiliation>
7                 <address><email>monyo@home.monyo.com</email></address>
8                 </affiliation>
9         </author>
10         <pubdate>25 March 2003</pubdate>
11 </chapterinfo>
12
13 <title>Unicode/Charsets</title>
14
15 <sect1>
16 <title>What are charsets and unicode?</title>
17
18 <para>
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>
28
29 <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 
35 store one character). 
36 </para>
37
38 <para>
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 
43 communicating.
44 </para>
45
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.
51 </para>
52 </sect1>
53
54 <sect1>
55 <title>Samba and charsets</title>
56
57 <para>
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: 
60 </para>
61
62 <variablelist>
63         <varlistentry>
64                 <term><parameter>unix charset</parameter></term>
65                 <listitem><para>
66                 This is the charset used internally by your operating system. 
67                 The default is <constant>ASCII</constant>, which is fine for most 
68                 systems.
69                 </para></listitem>
70         </varlistentry>
71
72         <varlistentry>
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>.
76                 </para></listitem>
77         </varlistentry>
78
79         <varlistentry>
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. 
86                 </para></listitem>
87         </varlistentry>
88 </variablelist>
89
90 </sect1>
91
92 <sect1>
93 <title>Conversion from old names</title>
94
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>
98
99 <para>The following script from Steve Langasek converts all 
100 filenames from CP850 to the iso8859-15 charset.</para>
101
102 <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' \;
105 </userinput>
106 </para>
107 </sect1>
108
109 <sect1>
110 <title>Japanese charsets</title>
111
112 <para>Samba doesn't work correctly with Japanese charsets yet. Here are
113 points of attention when setting it up:</para>
114
115 <itemizedlist>
116
117 <listitem><para>You should set <parameter>mangling method =
118 hash</parameter></para></listitem>
119
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>
124
125 <listitem><para>You should set <parameter>dos charset = CP932</parameter>, not
126 Shift_JIS, SJIS...</para></listitem>
127
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>
132
133 <listitem><para>Currently Samba 3.0 does not support <parameter>unix charset
134 = UTF8-MAC/CAP/HEX/JIS*</parameter></para></listitem>
135
136 </itemizedlist>
137
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>
139
140 </sect1>
141
142 </chapter>