Whenever we create a file, you can choose the type of coding in different text editors.
My question is, when using php, make reading a file, but the file is not specified in bytes if it is (UTF8, ISO 8859-1, ANSI ...).
But I realize that there are "bits" at the end of that file because the php returns the last STRING with 0. string '' (length = 0)
<?php
$leitor = fopen('2.php','rb');
while(!feof($leitor)){
var_dump(fread($leitor, 1));
}
fclose($leitor);
?>
I believe that this part should contain the type of encoding (UTF-8, ANSI ...)
1) Where is informed on the type of file encoding (UTF8 - 000001, ANSI - 000011)?
2) How do I read "bits" with php actually want to read these last bits that are represented by:
string '' (length = 0)
Because I can do it with the bytes:
function BinString2BitSequence1($mystring) {
$result = "";
$end = strlen($mystring);
for($i = 0 ; $i < $end; $i++){
$result .= str_pad(decbin(ord($mystring[$i])), 8, '0', STR_PAD_LEFT);
}
return $result;
}