Utf-8 BIG problems


#1

hey,


i have change my db to utf8-general-ci, now all the characters are
correct in
the database, i need this for exporting to pdf en excel. now i can also
import
from csv, characters like éà ï…

But the display is then fucked up. i get wierd symbols

Another situation:
I have seen a post here to add to environment.rb:
$KCODE = ‘UTF8’
require ‘jcode’

and to application.rb:
before_filter :configure_charsets
after_filter :fix_unicode_for_safari

def parse_errors(obj)
	return nil if obj.nil?

	str = "<ul>"
	obj.errors.each_full do |msg|
	str += "<li>" + msg +"</li>"
	end
	str += "</ul>"
	return str
end

	def configure_charsets
    @headers["Content-Type"] = "text/html; charset=utf-8"
    suppress(ActiveRecord::StatementInvalid) do
      ActiveRecord::Base.connection.execute 'SET NAMES UTF8'
    end
end

then the display is correct but when i export to pdf and excel i get the
wierd
characters again. and when i want to import form csv, u can read here
http://article.gmane.org/gmane.comp.lang.ruby.rails/33840

but i need all correct characters in the database, cuz i also work with
xml and
soap and ajax.


I prefer to use the 1st solution (correct import and export, incorrect
display)
and find a solution for the display.

Can anyone help me??

thanks in advance


#2

hey, if found a temp solution for this

for showing, editing, xml ==>> u need utf8
in the def

@headers[“Content-Type”] = “text/html; charset=utf-8”
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute ‘SET NAMES UTF8’
end

for pdf, excel, import csv ==>> u need latin1, iso-8859-1
in the def

@headers[“Content-Type”] = “application/pdf; charset=iso-8859-1”
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute ‘SET NAMES latin1’
end