[erlang-questions] Some problem abount odbc?

sky <>
Thu Dec 2 03:11:03 CET 2010


Hi michael,

I got the correct result by using unicode module: 
unicode:characters_to_list(Data, {utf16, little}.
Thank you very much!

于 2010-12-2 3:07, Michael Santos 写道:
> On Wed, Dec 01, 2010 at 10:28:27AM +0800, sky wrote:
>
>> When i used odbc to connect a sql server database, i met some
>> problem???all string data which returned by odbc:sql_query() has been
>> convert to binary,
>> even though i set option binary_strings=off,
> binary_strings=off only works with SQL_C_CHAR data. The data type returned
> by nvarchar is SQL_C_WCHAR.
>
>> what's the matter? And how
>> could i get the string format?
>>
>> the original string is "192.168.0.4", and the convert binary is
>> <<49,0,57,0,50,0,46,0,49,0,54,0,56,0,46,0,48,0,46,0,52,0>>. and the
> The returned data is unicode, 2 bytes representing each character:
> "1\09\02\0.\01\06\08\0.\00\0.\04\0".
>
>> datatype of the string is nvarchar???
> Try converting the data to varchar or using the unicode module:
>
> 1>  IP =<<49,0,57,0,50,0,46,0,49,0,54,0,56,0,46,0,48,0,46,0,52,0>>.
> <<49,0,57,0,50,0,46,0,49,0,54,0,56,0,46,0,48,0,46,0,52,0>>
>
> 2>  unicode:characters_to_list(IP, {utf16,little}).
> "192.168.0.4"
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature database 5619 (20101114) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>



More information about the erlang-questions mailing list