C++

How can I detect if a file is utf16 or utf18

How can I detect if a file is utf16 or utf18, or i general - resources about the somewhat related topics like encodings, unicode, text file formats, boms, line endings etc etc?
You already invited:

plante

Upvotes from:

You can check for a BOM.
if not present, I don’t know of nay built in identifications, you either have to know or guess, e.g. decode part of the file and see if it decodes correctly and maps to some language
Byte Order Mark, it’s optional and almost never present :
 
You can look for ideas in the `file(1)` utility

If you wanna answer this question please Login or Register