[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Autodetect encoding / mojibake correction?

Cameron Adamez

10/24/2006 8:13:00 PM

Hi,
Is there something to automatically detect what encoding a file is? That
way, I don't have to guess when using iconv.
Also, is there a script/gem/etc that can correct mojibake? If not, I want
to write it... though I'm not quite sure how...

Thanks,
Cameron

1 Answer

Zev Blut

10/25/2006 10:04:00 AM

0

Hi,

On Wed, 25 Oct 2006 05:12:53 +0900, Cameron Adamez <cameron@soycow.org>
wrote:

> Hi,
> Is there something to automatically detect what encoding a file is? That
> way, I don't have to guess when using iconv.
> Also, is there a script/gem/etc that can correct mojibake? If not, I want
> to write it... though I'm not quite sure how...

Check our NKF and Kconv in Ruby's standard lib.

NKF.guess can be used for detecting some encodings.
There is also the Kconv lib for making some encoding conversions.

I hope that helps,

Zev