How does smbclient know what character sets to use?
ab at altlinux.ru
Thu Aug 12 07:37:09 GMT 2004
On Wed, Aug 11, 2004 at 02:54:36PM -0700, David Wuertele wrote:
> Is there a standard character set used by the SMB protocol?
> If not, how does smbclient determine what character set to translate
> into the local host's character set?
During negotiation, both client and server could make decision on whether
they operate with Unicode or not. If former, than almost all exchanges are
done in UCS-2. If latter, then local meaning of the character set is used
with no way to communicate that meaning between client and server except
some information in INFO3 which theoretically could contain country
settings for the user logged in but in practice in any Windows versions we
usually see that field set to 0.
So it is pre-configuration task to make sure both client and server have the
same meaning of 'dos charset' in their options when one of them do not speak
Unicode on wire. In particular, it is impossible to have non-Unicode
clients with different 'dos charset' settings in the same workgroup as
this could affect badly any of them, especially when their NetBIOS names
include non-common characters.
> Also, how does smbclient discover what the local host's character set
> is? Is that what LANG is for?
smbclient utilises charset discovery for 'display charset' setting which
is used for displaying output of smbclient commands. By default, 'display
charset' option in smb.conf is set to 'LOCALE' which means "discover
charset set in environment". It is done by calling nl_langinfo(CODESET)
after applying environmental settings through setlocale(LC_ALL,"") (if
that is supported by the system).
So, from user point of view, it is managed by LANG variable or LC_*
variables for specific components though in our case only LANG and LC_ALL
setting is affected.
For more information about all these locale-oriented options please read
GNU Libc manual:
$ info libc Locales
/ Alexander Bokovoy
Samba Team http://www.samba.org/
ALT Linux Team http://www.altlinux.org/
Midgard Project Ry http://www.midgard-project.org/
More information about the samba-technical