Same file with different extension give different encoding on Apache server.
Exact same file show swedish letters when extension is .htm but show � when extension is .php
I tried with .htaccess and changing inside with charset=iso-8859-1 and UTF-8
Can’t find a solution but I thin it is in the server.
start at the beginning and troubleshoot the process.
here is an example using Windows OS and Notepad.
create a php file using Notepad. name"file.php" with save as type all files with encoding utf-8. N.b.: this saves with a bom. Notepadd++ will allow one to remove the bom by saving as utf-8. I just open my files in Notepadd++ to change to utf-8 encoding (no bom), then save.
be sure that you set a header and optional meta tag:
header('Content-Type: text/html; charset=utf-8');
if you want iso-8859-1, then save from notepad with encoding ANSI and set the header to:
header('Content-Type: text/html; charset=iso-8859-1');
optional <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
Thanks! Done all that, saved files as UTF8 in Notepadd++ but same problem appears - no swedish letter when file extension is .php. Same file but changed to .htm shows all swedish letter.
Server says standard is UTF8.
Tried with UTF8-BOM and that was the solution!
are you sending headers with apache? double check to be certain.
.htaccess file will have an obvious statement:
AddCharset iso-8859-1 .php
check php.ini file settings:
; PHP's default character set is set to UTF-8.
; http://php.net/default-charset
default_charset="UTF-8"
are you certain that php is running and it is working with apache?
finally, be absolutely certain that an overlooked meta tag isn’t changing it
a bom signature will create a “headers all ready sent” error, so this is not a solution.
“In some browsers, the presence of a UTF-8 signature will cause the browser to interpret the text as UTF-8 regardless of any character encoding declarations to the contrary.”
https://www.w3.org/International/questions/qa-utf8-bom.en
if a bom signature solved your problem, then something is using a character set other than utf-8