Function: detect-coding-region
detect-coding-region is a function defined in coding.c.
Signature
(detect-coding-region START END &optional HIGHEST)
Documentation
Detect coding system of the text in the region between START and END.
Return a list of possible coding systems ordered by priority.
The coding systems to try and their priorities follows what
the function coding-system-priority-list (which see) returns.
If only ASCII characters are found (except for such ISO-2022 control
characters as ESC), it returns a list of single element undecided
or its subsidiary coding system according to a detected end-of-line
format.
If optional argument HIGHEST is non-nil, return the coding system of highest priority.
Probably introduced at or before Emacs version 20.3.
Source Code
// Defined in /usr/src/emacs/src/coding.c
{
ptrdiff_t from, to;
ptrdiff_t from_byte, to_byte;
validate_region (&start, &end);
from = XFIXNUM (start), to = XFIXNUM (end);
from_byte = CHAR_TO_BYTE (from);
to_byte = CHAR_TO_BYTE (to);
if (from < GPT && to >= GPT)
move_gap_both (to, to_byte);
return detect_coding_system (BYTE_POS_ADDR (from_byte),
to - from, to_byte - from_byte,
!NILP (highest),
!NILP (BVAR (current_buffer
, enable_multibyte_characters)),
Qnil);
}