Using PHP5 (cgi) to output template files from the filesystem and having issues spitting out raw HTML.
private function fetch($name) {
$path = $this->j->config['template_path'] . $name . '.html';
if (!file_exists($path)) {
dbgerror('Could not find the template "' . $name . '" in ' . $path);
}
$f = fopen($path, 'r');
$t = fread($f, filesize($path));
fclose($f);
if (substr($t, 0, 3) == b'\xef\xbb\xbf') {
$t = substr($t, 3);
}
return $t;
}
Even though I've added the BOM fix I'm still having problems with Firefox accepting it. You can see a live copy here: http://ircb.in/jisti/ (and the template file I threw at http://ircb.in/jisti/home.html if you want to check it out)
Any idea how to fix this? o_o
This global funtion resolve for UTF-8 system base charset. Tanks!
if anybody using csv import then below code useful
you would use the following code to remove utf8 bom
An extra method to do the same job:
The other methods I found cannot work in my case.
Hope it helps in some special case.
b'\xef\xbb\xbf'
stands for the literal string "\xef\xbb\xbf". If you want to check for a BOM, you need to use double quotes, so the\x
sequences are actually interpreted into bytes:Your files also seem to contain a lot more garbage than just a single leading BOM:
try:
:)