NameException 0 Posted December 19, 2011 Report Share Posted December 19, 2011 Boa tarde, Estou com dificuldade em escrever texto na codificação correcta, em ruby. Exemplo: text = "olá" puts text Output: ol├í Podem ajudar? Obrigado Link to post Share on other sites
Rui Carlos 367 Posted December 19, 2011 Report Share Posted December 19, 2011 Verifica se estás a usar o mesmo encoding no código fonte e no terminal onde executas o programa. Rui Carlos Gonçalves Link to post Share on other sites
NameException 0 Posted December 19, 2011 Author Report Share Posted December 19, 2011 Olá Rui, Na consola de windows: C:\>chcp Active code page: 437 Estou a utilizar a versão de ruby 1.8.6, que utiliza o encoding UTF-8. O problema está em fazer a conversão entre estes encodings... Link to post Share on other sites
NameException 0 Posted December 21, 2011 Author Report Share Posted December 21, 2011 Boa tarde, Partilho aqui o que procurava: class String require 'iconv' def to_iso Iconv.conv('ISO-8859-1', 'utf-8', self) end end Cumprimentos Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now