Re: How to guess or check encoding of text file.
On Mon, Jan 06, 2003 at 04:24:19PM +0900, Tomohiro KUBOTA wrote:
> Hi,
>
> From: Osamu Aoki <osamu@debian.org>
> Subject: How to guess or check encoding of text file.
> Date: Sun, 5 Jan 2003 22:56:11 -0800
>
> > Is there good utility to guess what encoding a test file is using? This
> > does not need to be generic but just for western language is fine.
>
> How about trying iconv? If it is not intended encoding, it errors.
>
> For example, if
>
> iconv -f UTF-8 -t ISO-8859-1 <somefile
>
> succeeds, it means the file is UTF-8. Thus, I wrote the following script:
>
>
> #!/bin/sh
> if iconv -f UTF-8 -t UTF-8 <$1 &>/dev/null
> then
> echo UTF-8
> else
> echo ISO-8859-1
> fi
Bingo :) Maybe this can be wishlist for iconv.
Thanks.
--
~\^o^/~~~ ~\^.^/~~~ ~\^*^/~~~ ~\^_^/~~~ ~\^+^/~~~ ~\^:^/~~~ ~\^v^/~~~ +++++
Osamu Aoki <osamu@debian.org> Cupertino CA USA, GPG-key: A8061F32
.''`. Debian Reference: post-installation user's guide for non-developers
: :' : http://qref.sf.net and http://people.debian.org/~osamu
`. `' "Our Priorities are Our Users and Free Software" --- Social Contract
Reply to: