I fixed the iconv code to work in windows. The "ignore" and "translit"
need to be reversed. It looks like its a bug in the
acts_as_permalink_fu plugin:

def escape(str)
      s = (Iconv.iconv('ascii//ignore//translit', 'utf-8', str)).to_s
      s.gsub!(/[^\w -]+/, '') # strip unwanted characters
      s
    end

However the exact same code did not work when run in the Heroku
environment. It still converted  "Mötley Crüe" to "Mtley Cre"

Hope someone can help

Steve

On Jun 17, 8:53 pm, SteveG <[EMAIL PROTECTED]> wrote:
> Thanks Morten. I assumed that was the problem.
>
> What I am trying to go is convert UTF to Ascii and have the ascii text
> still be readable. The code has to work in 3 different development
> environments :windows xp (I know it sucks but its all I have at home),
> osx (development at work when I have free time) and Heruko. The
> unicode gem was the only code I got working in both Windows and OSX.
> Here is the code:
>
> Unicode.normalize_KD(text).gsub(/[^\x00-\x7F]/n,'')
>
> This would convert a string like Mötley Crüe to Motley Crue which is
> exactly what I want.
>
> I just now lifted the following code from the acts_as_permalink_fu
> that uses iconv and it did not work with Heroku.  Mötley Crüe became
> Mtley Cre
>
> def escape(str)
>       s = (Iconv.iconv('ascii//translit//IGNORE', 'utf-8', str)).to_s
>       s.gsub!(/[^\w -]+/, '') # strip unwanted characters
>       s
>     end
>
> For some reason Iconv gives my a "invalid encoding" error in Windows,
> but that is a different issue.
>
> I hope you know of some alternatives/suggestions.
>
> Thanks,
>
> Steve
>
> On Jun 16, 5:49 pm, Morten Bagai <[EMAIL PROTECTED]> wrote:
>
> > Hi Steve,
>
> > The reason it's not installing is because the gem has binary
> > dependencies and compiles native extensions. I noticed it's a very,
> > very old gem release (9 years), and I couldn't find much info on it
> > online. If it's possible for you to share a bit more info on how
> > you're using it, we might be able to suggest a way of doing the same
> > thing with more recent and easily supported libraries.
>
> > Best,
>
> > /Morten
>
> > On Jun 16, 2008, at 8:29 AM, SteveG wrote:
>
> > > Anyone?
>
> > > On Jun 11, 5:01 pm, SteveG <[EMAIL PROTECTED]> wrote:
> > >> Hello all,
>
> > >> I just tried to install the unicode gem and it does not look like it
> > >> is loading. The Gem looked like it installed correct since its in the
> > >> gems directory. Any ideas? I tried from both the console and a
> > >> controller
>
> > >> Thanks,
> > >> Steve
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to