[erlang-questions] Some problem abount odbc?
Michael Santos
michael.santos@REDACTED
Wed Dec 1 20:07:45 CET 2010
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"
More information about the erlang-questions
mailing list