detect-coding-string
detect-coding-string is a built-in function in `C source code
'.
(detect-coding-string STRING &optional HIGHEST)
Detect coding system of the text in STRING.
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.