SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Lithuania, Europe
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    iconv and TRANSLIT

    OK, I cannot understand what the problem is. Here's my example:

    Code PHP:
    setlocale(LC_ALL, 'en_US.utf8');
    echo iconv('utf-8', 'ASCII//TRANSLIT', 'ąčęėįšųūž');
    // expected output: aceeisuuz
    // actual output: ?????????

    How come? The locale is set, but I still get those ?'s for some reason. Could it be a problem of my OS (CENTOS Enterprise 4.7)? The PHP version is 5.2.6.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    The incorrect or missing html character setting on the browser (or whatever), or webpage displaying the output?

  3. #3
    SitePoint Addict wibble wobble's Avatar
    Join Date
    Dec 2008
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've never used iconv so this might not be correct, but you might need to change the encoding in the html or response headers. Also, try using 'iso-8859-1' instead of 'ascii//translit'
    Find freelance jobs from all the major sites in one place:
    on twitter / on the web / twitter rss feed

  4. #4
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Lithuania, Europe
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Guys, HTML/response headers has nothing to do with the problem. It's not my browser that doesn't display the characters - iconv function itself outputs ?'s. Besides, ISO-8859-1 is not what I need at all. I need to transliterate the string.

    The interesting thing is that on one of my servers the same works just fine (CENTOS Enterprise 5.2 x86_64), but on the other it doesn't (CENTOS 4.7 i686). It even works on my Vista laptop...

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Well, I said browser but it could just as easily be a setting in your editor ( or your os )

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What encoding is your php source file saved in?
    Me thinks it better be utf8 otherwise it won't work(it contains a utf8 string).

  7. #7
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Lithuania, Europe
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is utf-8 encoded.

  8. #8
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does this tell you on the problem server?
    PHP Code:
    var_dump(setlocale(LC_ALL'en_US.utf8')); 

  9. #9
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Lithuania, Europe
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The locale 'en_US.utf8' IS supported by the server. It's one of those returned by the 'locale' command.


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
  •