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.


In reply to DBD::Sybase and UTF-8 by elfranne

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.