FreeTDS: How to set charset of parameters running stored procedure

前端 未结 1 817
日久生厌
日久生厌 2021-01-17 00:58

I have a C program connecting to a MSSQL database through FreeTDS.

I\'m trying to execute a stored procedure with a varchar parameter set to something like "Saíd

相关标签:
1条回答
  • 2021-01-17 00:59

    After a lot of attempts, I couldn't figure out why freetds.conf settings (client charset and tds version) are not being respected. At least, when I append TDS_Version=8.0;ClientCharset=UTF-8 into the connection string, it works!

    "Driver={FreeTDS};Server=%s;Port=%s;Database=%s;UID=%s;PWD=%s;APP=%s;TDS_Version=8.0;ClientCharset=UTF-8"
    

    Also, the header of freetds log file is changed, mentioning UTF-8 conversion:

    log.c:196:Starting log file for FreeTDS 0.91
            on 2016-05-18 15:58:49 with debug flags 0x4fff.
    iconv.c:330:tds_iconv_open(0xaeb19118, UTF-8)
    iconv.c:353:Using trivial iconv
    iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
    iconv.c:187:local name for UTF-8 is UTF-8
    iconv.c:187:local name for UCS-2LE is UCS-2LE
    iconv.c:187:local name for UCS-2BE is UCS-2BE
    iconv.c:349:setting up conversions for client charset "UTF-8"
    iconv.c:351:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
    iconv.c:391:preparing iconv for "ISO-8859-1" <-> "UCS-2LE" conversion
    iconv.c:394:tds_iconv_open: done
    
    0 讨论(0)
提交回复
热议问题