3 ms·
What's causing this? ruby-1.8.7-p302 > "Where is the bathroom?".to_spanish => "\302\277D\303\263nde est\303\241 el ba\303\261o?"
by callmeed 16y ago
What's causing this?
ruby-1.8.7-p302 > "Where is the bathroom?".to_spanish
=> "\302\277D\303\263nde est\303\241 el ba\303\261o?"
- comron 16y agoListed under "Roadmap" in the readme is the following: Investigate Unicode support for Ruby 1.8. to_lang has only been tested with 1.9. Do you have a copy of 1.9 to test with?
- callmeed 16y agoAh, yes. Much better: ruby-1.9.2-p0 > "Where is the bathroom?".to_spanish => "¿Dónde está el baño?" Thanks
- rsoto 16y agoAccents and special chars, I think it is trying to output "¿Dónde está el baño?"
- deleted 16y ago[deleted]
- carbon8 16y agoRuby 1.8 displays non-ascii characters in the shell using octal escape sequences. \302\277 is ¿, \303\263 is ó and so forth. It should be fine to work with (eg, saving to a database or displaying in a template) as long as you know the encoding. I just glanced at the code, but it looks like it just takes whatever the Google Translate API gives it, which I'm guessing is UTF-8.