SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2014
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php character encoding problem

    Sorry I'm kind of new to this site so I'm not exactly sure how this works. I have a php character encoding problem. Basically my program needs to take in characters, some of which are special characters and display their values. Here is a simplified version of the part which doesn't work:

    $string = "français";
    for ($i = 0; $i < strlen($string); $i++)
    {
    echo ord($string[$i]) . " ";
    }

    The problem comes about when it tries to echo ord($string[$i]) when i equals 4 at which point it must echo ord(ç) which doesn't work for some reason. What could I do instead so that it gives me the right value for ç and other special characters?

  2. #2
    SitePoint Enthusiast scout1idf's Avatar
    Join Date
    Nov 2009
    Location
    Ohio
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using the code you posted.....
    Code:
    $string = "français";
    for ($i = 0; $i < strlen($string); $i++)
    {
    echo ord($string[$i]) . " ";
    }
    my results are......
    Code:
    102 114 97 110 195 167 97 105 115
    I assume that these are the results you are after.
    ---------------------------------------------------------------------------------------
    I'm using "EASYPHP" running PHP version 5.4.4 / Apache 2.4.2.
    (they have newer versions, but I'm happy with this one for home use.)


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
  •