On Thu, Dec 3, 2009 at 3:47 PM, James Edward Gray II
<
ja...@graysoftinc.com> wrote:
>
> How long should I wait before offering an answer? ;)
Well, at least half an hour apparently, as that is how long it takes
me to get impatient and come up with some half-baked solution myself.
:-)
James, rest assured that I consumed every bit of your series on Ruby
character encodings, with great enthusiasm I might add. I even
understood some of it.
> > I don't get how to convert those multibyte escape sequences into a real, actual character shown in my text editor.
> >
> > Any help would be appreciated. Thanks.
>
> The data you showed is encoded as UTF-8. I figured that out by dumping it to a file, and just printing it out in my terminal. I have my terminal set to use UTF-8, so the fact that I saw the proper character pretty much told me what it was.
This shows my complete misunderstanding of the topic I believe. I'm
ashamed of it, for sure.
The file in question actually, physically, literally had backslash
followed by numbers for every multibyte character. They weren't
escaped in my *view* -- they were literally escaped in the yaml
document. This is where my trouble came in.
>
> I also opened the file in TextMate though and peeked inside the File → Re-Open With Encoding menu to see what was checked. Again, UTF-8.
>
> Knowing that, putting Ruby in UTF-8 mode when you originally worked with the data may have been all that was needed. You could do that by using the -KU switch, or setting $KCODE = "U". Modern versions of Rails do this for you, if you load that environment.
>
> I can probably be more specific if you show me the script that got you into trouble in the first place… :)
Here's the file:
http://github.com/seven1m/onebody/blob/master/config/locales/pt.yml
Here's what the file used to look like, before I screwed it up:
http://github.com/seven1m/onebody/commit/42a72259c849fb33119f2391d2b01bc8d0de1e2b#diff-7
Again, I don't pretend to understand this stuff, but I did
sledgehammer my way to the solution I believe. Thanks for your help!
-Tim