SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: PHP and UTF-8

  1. #1
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:
    Code:
    <?php 
    $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") . '"/>
    					 </a>';
    }
    ?>
    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?

  2. #2
    SitePoint Member
    Join Date
    Apr 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone?

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2005
    Posts
    1,832
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    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:

    http://stackoverflow.com/questions/1...-utf-8-strings

    Also see:

    http://stackoverflow.com/questions/7...f-8-characters


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •