Forum: Ruby on Rails Changing encoding on text

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8aa68df8d14eff5681c8e87a073e8cca?d=identicon&s=25 Gitte Wange (Guest)
on 2005-12-28 19:25
(Received via mailing list)
Hello,

I have a set of templates creating some files for me. All data on my
site is encoded using iso-8859-1. Now I want to save the text in the
file using utf-8. I have tried using iconv, but whenever I have the
require "iconv" statement in my model, there is some error happening in
the model and the model doesn't get loaded (not sure how to debug that).

What approches to change encoding is there besides iconv?

Greetings,
Gitte Wange
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2005-12-28 20:40
(Received via mailing list)
On 12/28/05, Gitte Wange <gitte@wange.dk> wrote:
> Hello,
>
> I have a set of templates creating some files for me. All data on my
> site is encoded using iso-8859-1. Now I want to save the text in the
> file using utf-8. I have tried using iconv, but whenever I have the
> require "iconv" statement in my model, there is some error happening in
> the model and the model doesn't get loaded (not sure how to debug that).
>
> What approches to change encoding is there besides iconv?
>
Try opening an irb session, and typing:
require 'iconv'
Iconv.new('UTF-8', 'iso-8859-1').iconv('Test')

If that fails, at least you know your problem isn't Rails-specific.
If you're on Windows, your problem could easily be:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
8aa68df8d14eff5681c8e87a073e8cca?d=identicon&s=25 Gitte Wange (Guest)
on 2005-12-28 21:59
(Received via mailing list)
Wilson Bilkovich wrote:
>>What approches to change encoding is there besides iconv?
>>
>
> Try opening an irb session, and typing:
> require 'iconv'
> Iconv.new('UTF-8', 'iso-8859-1').iconv('Test')
>
> If that fails, at least you know your problem isn't Rails-specific.
> If you're on Windows, your problem could easily be:
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...

irb(main):001:0> require "iconv"
=> true
irb(main):002:0> Iconv.new('UTF-8', 'iso-8859-1').iconv('Test')
=> "Test"

So - the iconv module works.
I'm running it on freebsd so no windows issues here :-)

I'm really not sure where it goes wrong ...

Greetings,
Gitte Wange
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2005-12-28 22:17
(Received via mailing list)
On 12/28/05, Gitte Wange <gitte@wange.dk> wrote:
> >>
>
> irb(main):001:0> require "iconv"
> => true
> irb(main):002:0> Iconv.new('UTF-8', 'iso-8859-1').iconv('Test')
> => "Test"
>
> So - the iconv module works.
> I'm running it on freebsd so no windows issues here :-)
>
> I'm really not sure where it goes wrong ...
>

Anything showing up in the development log?
Can you create a test model that has the bare-minimum amount of code
required to produce the problem?  That might help isolate it.
8aa68df8d14eff5681c8e87a073e8cca?d=identicon&s=25 Gitte Wange (Guest)
on 2005-12-28 22:44
(Received via mailing list)
Wilson Bilkovich wrote:
>>>>site is encoded using iso-8859-1. Now I want to save the text in the
>>>
>>I'm running it on freebsd so no windows issues here :-)
>>
>>I'm really not sure where it goes wrong ...

Sorry for the inconvinience - the problem has magically disappeared. (I
suspect me testing code on one machine and testing the iconv stuff on
another). Sorry!

Greetings,
Gitte Wange
This topic is locked and can not be replied to.