Autodetect encoding / mojibake correction?


#1

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


#2

Hi,

On Wed, 25 Oct 2006 05:12:53 +0900, Cameron A. removed_email_address@domain.invalid
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