Problems with HStringTemplate UTF8 templates in ghc-6.12

Hi all, I need your help I have something i can't understand with hstringtemplate. I'm using this library in my project to render UTF-8 encoded templates. Everything was fine when I were using ghc-6.10 and hstringtemplate-0.6.1 But recently I upgraded to ghc-6.12 and hstringtemplate-0.6.2 and the output of my program now broken. I can see correctly only UTF8 values that I pass to template from database. It seems that toString method produces not UTF-8 encoded string, because if i use Codec.Binary.UTF8.String.encodeString i get correct output except for values from database. Any ideas how to solve the problem?

Dmitry Simonchik
But recently I upgraded to ghc-6.12 and hstringtemplate-0.6.2 and the output of my program now broken. I can see correctly only UTF8 values that I pass to template from database. It seems that toString method produces not UTF-8 encoded string, because if i use Codec.Binary.UTF8.String.encodeString i get correct output except for values from database.
What is your OSs locale? As of 6.12.1, GHC defaults to doing IO using the system's locale, which means you might be doubly encoding the String. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

My system locale is en_US.UTF-8 I've written an example app as following import Text.StringTemplate(render, directoryGroupRecursive, STGroup, getStringTemplate, setAttribute) import qualified Data.ByteString as BS main :: IO () main = do tg <- getTemplates "./" let (Just tmpl) = getStringTemplate "test" tg let res = render $ setAttribute "test" "Это проверка" tmpl BS.writeFile "./output.txt" res getTemplates :: FilePath -> IO (STGroup BS.ByteString) getTemplates path = directoryGroupRecursive path It just reads a test template and writes rendered result back to file. And I get corrupted output. On Sun, May 2, 2010 at 5:44 PM, Ivan Lazar Miljenovic < ivan.miljenovic@gmail.com> wrote:
But recently I upgraded to ghc-6.12 and hstringtemplate-0.6.2 and the output of my program now broken. I can see correctly only UTF8 values that I
Dmitry Simonchik
writes: pass to template from database. It seems that toString method produces not UTF-8 encoded string, because if i use Codec.Binary.UTF8.String.encodeString i get correct output except for values from database.
What is your OSs locale? As of 6.12.1, GHC defaults to doing IO using the system's locale, which means you might be doubly encoding the String.
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com
participants (2)
-
Dmitry Simonchik
-
Ivan Lazar Miljenovic