Rails & sqlserver collation problems

Boa tarde pessoal.

Estou utilizando o intant rails com ruby v.1.8.6 e rails 2.0.2 com um
servidor sqlserver2000, minha base de dados usa o collation
SQL_latin1_general_CP1_CI_AS, quando tragos strings com acentuao e
cedilha no consigo visualizar os carateres corretos, sei que para
exibir corretamente o texto no ruby tenho que usar UTF-8. Como posso
fazer pra mudar o collation da minha base ou converter as string para
UTF-8 na hora de exibir?

Desde j agradeo
Eduardo

Peo desculpas pelo meu Portugus. Estou usando o Google Translate. :slight_smile:

Voc precisa informar o arquivo database.yml que pretende conversar
com o banco de dados em UTF-8. Para fazer isso adicione encoding: utf8
para o seu banco de dados no database.yml. Deixe-me saber como isso
vai.

Obrigado,
B.

2011/2/23 Edu M. [email protected]:

On Wed, Feb 23, 2011 at 1:21 PM, Michael P. [email protected]
wrote:

Por favor, pare top postagem

“The traditional style was for a long time to post the answer below as
much
of the quoted original as was necessary to understand the reply (bottom
or
inline). Many years later, when email became widespread in business
communication, it however became a widespread policy to reply above the
entire original and leave it untouched (and without any prefixes at the
beginning of each line) below the reply.

2011/2/23 Bryan C. [email protected]:

Peo desculpas pelo meu Portugus. Estou usando o Google Translate. :slight_smile:

Por favor, pare top postagem

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

On 23 February 2011 22:42, Bryan C. [email protected]
wrote:

On Wed, Feb 23, 2011 at 1:21 PM, Michael P. [email protected] wrote:

Por favor, pare top postagem

“The traditional style was for a long time to post the answer below as much
of the quoted original as was necessary to understand the reply (bottom or
inline). Many years later, when email became widespread in business
communication, it however became a widespread policy to reply above the
entire original and leave it untouched (and without any prefixes at the
beginning of each line) below the reply.”

This list isn’t a business communication - it’s a reference resource,
and that “policy” was imposed because one company’s email software
that just “did it that way” - irregardless of any user preference.

Posting style - Wikipedia

Read the whole of that article… especially the section on “Choosing
the proper posting style”. If after that you still insist on
top-posting, so be it :-/
shrug

I reply to the email that I receive which uses the standard method of
top
posting. Why? Because if you bottom-posted all the time or unnecessarily
inline quoted it would make this thread:
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/6c25db52c2d743aaand
others like it unreadable.

I’m done discussing posting styles. Let’s return to helping each other
out
which is the main reason for this group.

On 23 February 2011 23:07, Bryan C. [email protected]
wrote:

I reply to the email that I receive which uses the standard method of top
posting.

What “standard”? Which RFC says that there is any “standard”?

if you … unnecessarily
inline quoted it would make this thread:

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/6c25db52c2d743aa

and others like it unreadable.

no… top-posting makes it impossible to maintain a coherent
conversation, and introduces confusion about what replies refer to,
because there’s no context.

I’m done discussing posting styles.

So I guess you didn’t bother reading the rest of the article you
waved as defence of your position? … hence my shrug

PS You’ve got a frightfully annoying email client too, which sends
to the person, and CCs the group - so further replies go to you, not
the group… :-/

Eu tentei usar o encoding: utf8 no database.yml, mas para o sql server
não funciona. tentei então um helper para a classe string com o
seguinte código

-----------------------------------------------------------code starts
here-----------------------------------------------------------------------

class String

Returns a valid DateTime object if the object can be converted

according to +format+, nil otherwise.

FIXME: Corrigir o erro de validação em colunas contendo data +

hora.

gem ‘chardet’
require ‘UniversalDetector’

def parse_date(format =
ActiveSupport::CoreExtensions::date::Conversions::DATE_FORMATS[:default])
begin
DateTime.strptime(self, format)
rescue ArgumentError
end
end

def to_utf8
@encode_type = UniversalDetector::chardet(self)[“encoding”]
#detects the str encoding
Iconv.iconv(“UTF-8”, @encode_type, self).to_s #converts the
current encoding to UTF-8 of the present string
end

end

-----------------------------------------------------------code ends
here-----------------------------------------------------------------------

O chardet é uma gem que pode retornar o tipo de codificação utilizada
na string, o tipo de codificação retornado para o
SQL_latin1_genreal_CP1_CI_AS é o ISO-8859-5 e o iconv consegue passar
a string para utf8, porém os resultados ainda não são satisfatórios
pois os caracteres acentuados e as cedilhas não são exibidos
corretamente. Veja abaixo:

O que deveria exibir:

Fundação Ecumênica de Proteção ao Excepcional - PARANC

está exibindo:

Fundaчуo Ecumъnica de Proteчуo ao Excepcional - PARANС

Sinto que estou chegando perto, alguém sabe como prosseguir deste
ponto?

Desde já agradeço
Edu