[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can not decode 0x93 and 0x94 to correct char

From: Stefan Monnier
Subject: Re: can not decode 0x93 and 0x94 to correct char
Date: Sat, 29 Sep 2007 09:47:37 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

> ; for cp1258
> (prefer-coding-system 'windows-1258)
> ; for displaying utf-8 encoded file
> (prefer-coding-system 'utf-8-emacs)
> ; for displaying chinese characters
> (prefer-coding-system 'gb2312)

> It would be a little problem. Because if I changed the gb2312 to gb18030
> or gbk, the first setting (prefer-coding-system 'windows-1258) would
> be failed.

I'm not sure what you mean by "would be failed", but when you use
prefer-coding-system, you have to realize that it's not quite as simple as
it sounds:
- first, the three statements above mean to try (in this order) first
  gb2312, then utf-8, then windows-1258.
- second, this order should not be chosen exclusively based on how often
  you expect to use each of those encodings.  Because it depends a lot of
  the frequency of false positives.  E.g. utf-8 should usually be first,
  because it has very few false positives (if the auto-detect decides it's
  utf-8, then it's very unlikely that the file isn't utf-8).
  OTOH window-1258 should *not* be first because it has many false
  positives: any file without a 0 byte in it is a valid windows-1258 file.

The second point is the main reason why the order of detection of coding
systems when reading a file should be the same as the order of preference to
choose a coding system to use when writing a file.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]