Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

DBD::Sybase and UTF-8

by elfranne (Initiate)
on Sep 27, 2011 at 15:30 UTC ( [id://928105]=perlquestion: print w/replies, xml ) Need Help??

elfranne has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am having some problems when getting some data from a MS-SQL server using DBD::Sybase: the encoding fails.

I am geting 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", $LO +GIN, $PASSWD);
but it does not help.

i added a variable to get some more logs from Freetds: export TDSDUMP=/tmp/freetds.log

llog.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 progr +ess" 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
I searched extensivly on google about this, and there is actually quite a lot of problems with M$ using CP1252 encoding...

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.

Replies are listed 'Best First'.
Re: DBD::Sybase and UTF-8
by mpeppler (Vicar) on Sep 28, 2011 at 07:13 UTC
    Hi,

    I would take this issue to the FreeTDS mailing list. I don't think that it is related to DBD::Sybase directly, or to perl, but rather to the way FreeTDS does charset conversions between the client and the server.

    Michael

      Any update? I am also seeing this exact same error in MSSQL
        Adding 'client charset = UTF-8' to /etc/freetds/freetds.conf, [global] section worked for me though it could also be added to a specific connection.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://928105]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2024-04-16 19:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found