On Fri, Feb 3, 2012 at 9:29 AM, Christian MICHON <[email protected]> wrote: > On Fri, Feb 3, 2012 at 1:41 AM, Jeremy Evans <[email protected]> wrote: >> On Feb 2, 1:26 pm, Peter Vandenabeele <[email protected]> wrote: >>> As I noted in this thread >>> >>> http://www.ruby-forum.com/topic/3496096 >>> >>> it may be that using Iconv in ruby gets deprecated >>> and the functionality is better implemented with >>> >>> Encoding::Converter >>> >>> http://www.ruby-doc.org/core-1.9.3/Encoding/Converter.html >> >> Christian already stated that he could not yet move to 1.9, so that's >> not an option. Certainly in ruby 1.9, you should be using the >> Encoding facility instead of Iconv, but in ruby 1.8, Iconv is the way >> to go. >> > > Interesting links anyway: thanks for sharing them Peter. And as > mentioned again by Jeremy, moving to 1.9 mode is not yet an option. > > My target is still to have the right encoded values in H2, so I did > not keep the utf8 as an intermediate format. Using the code share by > Jeremy (to_utf8/from_utf8 using iconv) worked, but the content from H2 > console was not the right one. > > Instead, I did an insertion in H2 of the right character (therefore > stored as unicode) and used sequel to query that record. This gave me > a specific mapping. I can live with this, as I'm already performing > some filters before insertions. > > What I did next was to create to_h2 and from_h2 in the class String. > This is dirty but it works: the content in the db is now the right > one, and my app is happy about it. > > You can see a snippet in this pastie: http://pastie.org/3307806 >
My bad. I got confused between what is typed in a interactive ruby session and the file content. \224 was not the octal code I should have used in the snippet, but 0xF6 or \366 instead. This is why on the terminal I was not getting the right content: I may have wrong encoding settings in my terminal or in the font I'm using. In the end, when I finished implementing my table, I realized the final code was equivalent to calling to_utf8, but in a very unfriendly way compared to Jeremy's. I've merged Jeremy's snippet into my code now instead, and all is fine, symbols included. Thx again -- Christian -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
