Unicode conversion in MSSQL 2017 using 13.1 odbc drivers RRS feed

  • Question

  • Hi,

    I am trying to convert a code to insert and select a SQL query, which I am running in Windows to Linux. It is a Unicode conversion part where I am trying to convert between UTF-8 to UCS-2. In Windows, wchar_t takes 2 bytes and in Linux, it takes 4 bytes.

    I am using Windows API's MultiByteToWideChar and WideCharToMultiByte in Windows.

    In Linux, I am using mbstowcs and wcstombs Api's.

    But in Linux, only the first character gets stored in the query string and rest of the characters gets truncated when we pass the string to SQLExecDirectW API.

    Can someone explain how the Unicode conversion takes place in Linux, whether we need to configure any <g class="gr_ gr_29 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="29" id="29">parameters ?</g>

    I tried inserting and retrieving the same Non-ASCII character through <g class="gr_ gr_41 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling gr-progress" data-gr-id="41" id="41">sqlcmd</g> utility and it works fine.

    • Edited by Ash46 Monday, February 12, 2018 9:35 AM
    Monday, February 12, 2018 9:33 AM

All replies

  • Good day Ash,

    Can you provide the code instead of stories which tried to describe what you do?

    In the meantime, please check that you use NVARCHAR(MAX) and not NVARCHAR. The default length is one char which might be your issue

    signature   Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]    [Linkedin]

    Sunday, June 9, 2019 11:39 AM