Skip to Content.
Sympa Menu

freetds - [freetds] Freetds + DBD-Sybase + UTF-8

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Tom Braarup Cuykens <meriadoc_brandebouc AT hotmail.com>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Freetds + DBD-Sybase + UTF-8
  • Date: Wed, 28 Sep 2011 10:43:36 +0200


I am having some problems when getting some data from a MS-SQL server using
DBD::Sybase and Freetds (version 0.82): the encoding fails.

I am getting those errors :

DBD::Sybase::st fetchrow_hashref failed: OpenClient message: LAYER = (0)
ORIGIN = (0) SEVERITY = (9) NUMBER = (99)
Message String: Some character(s) could not be converted into client's
character set. Unconverted bytes were changed to question marks ('?')
OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (9) NUMBER = (99)
Message String: Some character(s) could not be converted into client's
character set. Unconverted bytes were changed to question marks ('?')

The characters are most likely to be country (Denmark) specific characters (æ
ø å) but they are included in UTF-8. i am calling the db like this : my $dbh
= DBI->connect("DBI:Sybase:server=$SERVER", $LOGIN, $PASSWD);

freetds.conf :
host = localhost
port 1433
tds version = 8.0
charset = UTF-8
(the server is not actually at localhost but a tunnel)

I tried :
my $dbh = DBI->connect("DBI:Sybase:server=$SERVER;charset=CP1252", $LOGIN,
$PASSWD);

but it does not help.


I added a variable to get some more logs from Freetds: export
TDSDUMP=/tmp/freetds.log
(I only included the part that looked most interresting as it is nearly 7000
lines)

log.c:190:Starting log file for FreeTDS 0.82
on 2011-09-27 16:54:38 with debug flags 0x4fff.
iconv.c:363:iconv to convert client-side data to the "ANSI_X3.4-1968"
character set
iconv.c:516:tds_iconv_info_init: converting "US-ASCII"->"UCS-2LE"
iconv.c:516:tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"
net.c:210:Connecting to 127.0.0.1 port 1433 (TDS version 8.0)
net.c:264:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:303:tds_open_socket() succeeded
util.c:162:Changed query state from DEAD to IDLE
login.c:735:quietly sending TDS 7+ login packet
token.c:312:tds_process_login_tokens()
net.c:592:Received header

[...]

iconv.c:985:setting server single-byte charset to "CP1252"
iconv.c:516:tds_iconv_info_init: converting "US-ASCII"->"CP1252"
token.c:2292:tds->collation now

[...]

token.c:2166:tds_process_row(): reading column 19
token.c:1915:tds_get_data: type 39, varint size 2
token.c:1975:tds_get_data(): wire column size is 8
util.c:334:tdserror(0x820b170, 0x7d077c0, 2403, 0)
ct.c:334:ct_con_props() action = CS_GET property = 9108
ct.c:486:fetching userdata 0x8ec49e0
util.c:368:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:389:tdserror: returning TDS_INT_CANCEL(2)
util.c:162:Changed query state from READING to PENDING
ct.c:1555:inside ct_fetch()process_row_tokens returned 1
ct.c:1704:_ct_bind_data()
ct.c:1711:_ct_bind_data(): column_type: 56 column_len: 4
ct.c:2003:_ct_get_server_type(8)
ct.c:1890:_ct_get_client_type(type 56, user 0, size 4)
cs.c:463:cs_convert()
ct.c:2003:_ct_get_server_type(8)

[...]

I think the problem is that the MS-SQL server output is encoded in CP1252 and
the Freetds decodes it as it were ISO-8859-1.


Elfranne.




Archive powered by MHonArc 2.6.24.

Top of Page