PHP and UTF-8

Recently I have asked for help regarding an automated PHP gallery. The script is now finished, but i face one more problem.

Here is the script:

$directory = "path/of/directory";

foreach (glob($directory . "*.jpg") as $pathinfo) {
               echo '<a href="' . $pathinfo . '">
			         <img src="' . $pathinfo . '" width="500" height="333" title="' . basename($pathinfo, ".jpg") . '"/>

Since I’m in Croatia, I use special characters ( e.g. č, ć, š, đ, ž ). Html can read the characters fine, but PHP obviously has a problem with that. I’ve tried decoding and encoding, declaring the UTF-8 in the head of PHP, but nothing works. The problem is that it can’t read the directory path if there are special characters, but instead of echo-ing them correctly, i get “?”
Does anyone know how to enable special characters?


I’ve never had to deal with this issue. However, a little research seems to indicate that PHP is not capable of handling certain UTF-8 characters in file names or paths.

Possible work around:

Also see: