chickadee » charconv » detect-encoding

detect-file-encoding FILE #!optional LOCALEprocedure
detect-encoding STRING #!optional LOCALEprocedure

The detection procedures can correctly identify most common 'types' of encodings, such as UTF-8/16/32, EUC-*, ISO-2022-*, Shift_JIS or single-byte, without any need for specifying the locale. However, currently it doesn't include any statistical or linguistic routines, without which it can't distinguish between EUC-JP and EUC-KR, or between any of the single-byte encodings (including ISO-8859-*). In these cases you can specify a locale, such that in the event of a single-byte encoding a "de" locale would result in the default German single-byte encoding, ISO-8859-1.

The detect-file-encoding procedure also recognizes the Emacs-style

 -*- coding: foo -*-

signature in either of the first two lines.