php - Get a file's character encoding without reading entire file into memory -


i know if need character encoding of file in php can

var_dump (mb_detect_encoding (file_get_contents ("somefile.txt"))); 

however, doing big file not practical eats big chunk of memory.

is there way of determining character encoding reliably without having read entire file memory?

no, there no way of determining character encoding reliably without having read whole file.

reason: character codes differing ascii (which still base part of many encodings) randomly distributed in file. might chance in part did not read.

of course, encodings easy identify beginning, not question here.

(giving chance accept answer solution, although answer might have been given in comment, should not (so policy).)


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -