I recently encountered a strange problem on my website. Images with æ ø and å in them (Western European signs) Won’t display.
The character encoding on all sites is “Iso-8859-1”
I can print æ ø and å on the page without problems.
If I right click the “broken image” and choose properties, it displays the filename
with the european signs. (/admin/content/galleri/å.jpg)
the code for img looks like this
<img name='bilde'
src='content/{$_SESSION["linkname"]}/{$row["img"]}'
class='topmargin_ss leftmargin_ms rightmargin_s'
width='80' height='80'>
(Wasn’t allowed to post images so the code is without starting and ending brackets)
Made 4 files:
z.jpg
æ.jpg
ø.jpg
å.jpg
Only z.jpg shows up, they are the exact same jpg.
The images are uploaded using php code, which works, uploads to the right directory and has no problem with the european signs.
Does anybody know what could be causing this?
This
htmlentities('string', ENT_QUOTES, "UTF-8")works for me.For you that might be
You might need to apply
utf8_decode($string)to the URL, but I never needed to do that when using htmlentities with “UTF-8”.NOTE : This assumes that the page is already utf-8 encoded. This can be done using
header('Content-Type: text/html; charset=utf-8');. And the data in the db is saved as utf-8.This can be done by calling
mysql_set_charset('utf8');before you start making MySQL queries; the query"SET NAMES 'utf8'"does the same.