Answer the question
In order to leave comments, you need to log in
How to read file in binary file contents for json encode?
Is it possible somehow to read the file in binary file contents, for subsequent writing to an array and serialization to json ?
I try file_get_contents, when I try json_encode, I get an error:
son_encode(): Invalid UTF-8 sequence in argument
function file_get_contents_utf8($fn) {
$content = file_get_contents($fn);
return mb_convert_encoding($content, 'UTF-8',
mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true));
}
Answer the question
In order to leave comments, you need to log in
Why read in binary mode text file O_o?
Why convert anything if json_encode() always produces utf8 and json_decode() only understands utf8?
UPD: The solution is to use a separate table to store binary files, see comments below this answer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question