C++ File Reading Library – ANSI and Unicode

c++file-iounicode

I've read a few answers on here about reading Unicode files etc and most people point to UTF8-CPP or iconv.

None of the libraries that I found work for both ANSI and Unicode files, ideally I want one function which I pass a filename to and it will return the contents of that file and it won't matter what the encoding is, or is that not possible?

If so any suggestions how I would go about it?

Best Solution

Well, that is a binary read isn't ? All other forms are a matter of interpretation and then the exact encoding etc becomes important.

While due to BOM, unicode can be autodetected in some cases, it's not always there, and a failed detection mechanism then equals a broken program. I assume that is the reason why most people refrain from it.