trying to get HEAD building again. If you want the code
[gd/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>Features and Benefits</title>
17
18 <para>
19 Every industry eventually matures. One of the great areas of maturation is in
20 the focus that has been given over the past decade to make it possible for anyone
21 anywhere to use a computer. It has not always been that way, in fact, not so long
22 ago it was common for software to be written for exclusive use in the country of
23 origin.
24 </para>
25
26 <para>
27 Of all the effort that has been brought to bear on providing native language support
28 for all computer users, the efforts of the Openi18n organisation is deserving of
29 special mention. For more information about Openi18n please refer to: 
30 <link url="http://www.openi18n.org/">http://www.openi18n.org/</link>.
31 </para>
32
33 <para>
34 Samba-2.x supported a single locale through a mechanism called 
35 <emphasis>codepages</emphasis>. Samba-3 is destined to become a truly trans-global
36 file and printer sharing platform.
37 </para>
38
39 </sect1>
40
41 <sect1>
42 <title>What are charsets and unicode?</title>
43
44 <para>
45 Computers communicate in numbers. In texts, each number will be 
46 translated to a corresponding letter. The meaning that will be assigned 
47 to a certain number depends on the <emphasis>character set(charset)
48 </emphasis> that is used. 
49 A charset can be seen as a table that is used to translate numbers to 
50 letters. Not all computers use the same charset (there are charsets 
51 with German umlauts, Japanese characters, etc). Usually a charset contains 
52 256 characters, which means that storing a character with it takes 
53 exactly one byte. </para>
54
55 <para>
56 There are also charsets that support even more characters, 
57 but those need twice(or even more) as much storage space. These 
58 charsets can contain <command>256 * 256 = 65536</command> characters, which
59 is more then all possible characters one could think of. They are called 
60 multibyte charsets (because they use more then one byte to 
61 store one character). 
62 </para>
63
64 <para>
65 A standardised multibyte charset is unicode, info is available at 
66 <ulink url="http://www.unicode.org/">www.unicode.org</ulink>. 
67 A big advantage of using a multibyte charset is that you only need one; no 
68 need to make sure two computers use the same charset when they are 
69 communicating.
70 </para>
71
72 <para>Old windows clients used to use single-byte charsets, named 
73 'codepages' by Microsoft. However, there is no support for 
74 negotiating the charset to be used in the smb protocol. Thus, you 
75 have to make sure you are using the same charset when talking to an old client.
76 Newer clients (Windows NT, 2K, XP) talk unicode over the wire.
77 </para>
78 </sect1>
79
80 <sect1>
81 <title>Samba and charsets</title>
82
83 <para>
84 As of samba 3.0, samba can (and will) talk unicode over the wire. Internally, 
85 samba knows of three kinds of character sets: 
86 </para>
87
88 <variablelist>
89         <varlistentry>
90                 <term><parameter>unix charset</parameter></term>
91                 <listitem><para>
92                 This is the charset used internally by your operating system. 
93                 The default is <constant>ASCII</constant>, which is fine for most 
94                 systems.
95                 </para></listitem>
96         </varlistentry>
97
98         <varlistentry>
99                 <term><parameter>display charset</parameter></term>
100                 <listitem><para>This is the charset samba will use to print messages
101                 on your screen. It should generally be the same as the <command>unix charset</command>.
102                 </para></listitem>
103         </varlistentry>
104
105         <varlistentry>
106                 <term><parameter>dos charset</parameter></term>
107                 <listitem><para>This is the charset samba uses when communicating with 
108                 DOS and Windows 9x clients. It will talk unicode to all newer clients.
109                 The default depends on the charsets you have installed on your system.
110                 Run <command>testparm -v | grep "dos charset"</command> to see 
111                 what the default is on your system. 
112                 </para></listitem>
113         </varlistentry>
114 </variablelist>
115
116 </sect1>
117
118 <sect1>
119 <title>Conversion from old names</title>
120
121 <para>Because previous samba versions did not do any charset conversion, 
122 characters in filenames are usually not correct in the unix charset but only 
123 for the local charset used by the DOS/Windows clients.</para>
124
125 <para>The following script from Steve Langasek converts all 
126 filenames from CP850 to the iso8859-15 charset.</para>
127
128 <para>
129 <prompt>#</prompt><userinput>find <replaceable>/path/to/share</replaceable> -type f -exec bash -c 'CP="{}"; ISO=`echo -n "$CP" | iconv -f cp850 \
130   -t iso8859-15`; if [ "$CP" != "$ISO" ]; then mv "$CP" "$ISO"; fi' \;
131 </userinput>
132 </para>
133 </sect1>
134
135 <sect1>
136 <title>Japanese charsets</title>
137
138 <para>Samba doesn't work correctly with Japanese charsets yet. Here are
139 points of attention when setting it up:</para>
140
141 <itemizedlist>
142
143 <listitem><para>You should set <parameter>mangling method =
144 hash</parameter></para></listitem>
145
146 <listitem><para>There are various iconv() implementations around and not
147 all of  them work equally well. glibc2's iconv() has a critical problem
148 in CP932.  libiconv-1.8 works with CP932 but still has some problems and
149 does not  work with EUC-JP.</para></listitem>
150
151 <listitem><para>You should set <parameter>dos charset = CP932</parameter>, not
152 Shift_JIS, SJIS...</para></listitem>
153
154 <listitem><para>Currently only <parameter>unix charset = CP932</parameter>
155 will work (but still has some problems...) because of iconv() issues.
156 <parameter>unix charset = EUC-JP</parameter> doesn't work well because of
157 iconv() issues.</para></listitem>
158
159 <listitem><para>Currently Samba 3.0 does not support <parameter>unix charset
160 = UTF8-MAC/CAP/HEX/JIS*</parameter></para></listitem>
161
162 </itemizedlist>
163
164 <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>
165
166 </sect1>
167
168 </chapter>