Skip to Content.
Sympa Menu

freetds - Re: [freetds] Question of Charset

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Question of Charset
  • Date: Sun, 7 Mar 2004 14:08:35 -0500

On Sun, 07 Mar 2004, edwardspl AT ita.org.mo wrote:
> After enter chinese words though program ( Web ) to MS-SQL, then search
> the data from the DB...
> But the result of the records is not chinese words ( char ) !
>
> So, how to specify the client charset in freetds.conf ?

Edward,

I don't speak or read Chinese, and have no experience setting up Chinese
support for FreeTDS. I'll tell you what I know.

Understand that we added UTF-8 support for FreeTDS. To use it, your
client needs UTF-8 locale settings, including UTF-8 fonts. Other
encodings *might* work; I know other Japanese encodings have been reported
to work. Which encoding are you using?

In general, first be sure libiconv is used:

$ tsql -C |grep iconv
iconv library: yes

Check your iconv's Chinese support:

$ iconv -l |grep -Ei 'chinese|big'
UCS-2BE UNICODE-1-1 UNICODEBIG CSUNICODE11
CHINESE GB_2312-80 ISO-IR-58 CSISO58GB231280
BIG-5 BIG-FIVE BIG5 BIGFIVE CN-BIG5 CSBIG5
BIG5-HKSCS BIG5HKSCS

Put the name in freetds.conf:

[myserver]
host = foo.bar.com
port = 1433
tds version = 7.0
client charset = UTF-8 # BIG-5 might work

That should do it, as far as FreeTDS is concerned. You can check with
TDSDUMP:

jklowden AT oak.schemamania.org$ export TDSDUMP=stdout
jklowden AT oak.schemamania.org$ tsql -S$S -U$U -P$P |head -20
locale is "C"
locale charset is "646"
Starting log file for FreeTDS 0.63.dev.20040125
on 2004-03-07 13:53:54 with debug level 99.
names for ISO-8859-1: ISO-8859-1
names for UTF-8: UTF-8
names for UCS-2LE: UCS-2LE
names for UCS-2BE: UCS-2BE
iconv to convert client-side data to the "646" character set
13:53:54.414280 tds_iconv_info_init: converting "US-ASCII"->"UCS-2LE"
13:53:54.414314 tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"

(You would see your character set name instead of these.)

At this point, tsql *should* show Chinese characters resulting from a
query, as long as the data come from a nchar, ntext, or nvarchar columns.


I don't know much about PHP. Others here do, though. Good luck!

--jkl







Archive powered by MHonArc 2.6.24.

Top of Page