Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. HDBC-ODBC and Windows-1251 encoding (Sergiy Nazarenko)
----------------------------------------------------------------------
Message: 1
Date: Thu, 26 Jan 2012 11:13:43 +0200
From: Sergiy Nazarenko <[email protected]>
Subject: [Haskell-beginners] HDBC-ODBC and Windows-1251 encoding
To: [email protected]
Message-ID:
<CAHbuS7Jz+qHY5wZLddQkPuy=mpqkrm23d4hhv-tnr3o+rhz...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi, guys!
I use HDBC-ODBC module to work with windows data base and I got
following problem:
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
cast specification
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?
Cheers,
Sergiy
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 43, Issue 30
*****************************************