[Haskell-beginners] HDBC-ODBC and Windows-1251 encoding
nazarenko.sergiy at gmail.com
Thu Jan 26 10:13:43 CET 2012
I use HDBC-ODBC module to work with windows data base and I got
when I try to do INSERT
> import Codec.Text.IConv (convert)
> import qualified Data.ByteString.Lazy as BSL
> let name = convert "UTF-8" "WINDOWS-1251" $ BSL.pack "bla"
> quickQuery "INSERT INTO Mytable (name,descript) VALUES (?, ?)" [toSql name), toSql name]
and this also not worked:
> quickQuery "INSERT INTO Mytable (name,descript) VALUES (?, ?)" [toSql ( BS.pack "bla "), toSql ( BS.pack "blabla" )]
MSSQL server response me error:
... [ODBC SQL Server Driver][SQL Server]Invalid character value for
It seems to be different encoding then HDBC-ODBC module can work with.
I read documentation for HDBC:
> To accomplish this, whenever a ByteString must be converted to or from a String, the ByteString is assumed to be in UTF-8 encoding, and will be decoded or encoded as appropriate.
> Database drivers will generally present text or string data they have received from the database as a SqlValue holding a ByteString, which fromSql will automatically convert to a String, and thus automatically decode UTF-8, when you need it. In the other direction, database drivers will generally convert a SqlString to a ByteString in UTF-8 encoding before passing it to the database engine.
How can I work with HDBC-ODBC module with non UTF-8 encoding?
More information about the Beginners