logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$5
Handling Turkish characters

I do not have much experience with internationalization, so I'll post this here. Unsal discovered a bug in WordPress and posted a ticket on the WordPress site. The bug involves Turkish characters. Then he posted it to our WordPress site (which is built using Symfony) and found that his Turkish characters were not coming through. This is perhaps a matter of character encoding? What encoding do I need to set to allow his characters to come through on our WordPress site?

This question has been answered.

Lawrence Krubner | 03/01/10 at 3:58pm Edit


(4) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    03/05/10
    3:00pm
    Kiril Angov says:

    You need to make sure you database table use UTF-8. I am sure you use same HTML sanitizer for the input box to make sure you allow only the whitelisted tags, so make sure it is UTF-8 safe. Also try with other UTF-8 characters and see if they work.

  • avatar
    Last edited:
    03/01/10
    6:40pm
    Gert Findel says:

    Kiril is right about utf-8 encoding for the database and the site. Utf-8 is enough for Turkish

    It looks like you are using like the slugify method from the jobeet tutorial chapter 8 (because its a permalink)


    // code derived from http://php.vrana.cz/vytvoreni-pratelskeho-url.php
    static public function slugify($text)
    {
    // replace non letter or digits by -
    $text = preg_replace('~[^\\pL\d]+~u', '-', $text);

    // trim
    $text = trim($text, '-');

    // transliterate
    if (function_exists('iconv'))
    {
    $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
    }

    // lowercase
    $text = strtolower($text);

    // remove unwanted characters
    $text = preg_replace('~[^-\w]+~', '', $text);

    if (empty($text))
    {
    return 'n-a';
    }

    return $text;
    }


    You might want to check that and correct properly not replacing the non-utf-8.

    attachment image View Attachment

    • 03/01/10 6:40pm

      Gert Findel says:

      Kiril is right about utf-8 encoding for the database and the site. Utf-8 is enough for Turkish

      It looks like you are using like the slugify method from the jobeet tutorial chapter 8 (because its a permalink)


      // code derived from http://php.vrana.cz/vytvoreni-pratelskeho-url.php
      static public function slugify($text)
      {
      // replace non letter or digits by -
      $text = preg_replace('~[^\\pL\d]+~u', '-', $text);

      // trim
      $text = trim($text, '-');

      // transliterate
      if (function_exists('iconv'))
      {
      $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
      }

      // lowercase
      $text = strtolower($text);

      // remove unwanted characters
      $text = preg_replace('~[^-\w]+~', '', $text);

      if (empty($text))
      {
      return 'n-a';
      }

      return $text;
      }


      You might want to check that and correct properly not replacing the non-utf-8.

      Attached Image

    • 03/01/10 6:43pm

      Gert Findel says:

      Kiril is right about utf-8 encoding for the database and the site. Utf-8 is enough for Turkish

      It looks like you are using like the slugify method from the jobeet tutorial chapter 8 (because its a permalink)


      // code derived from http://php.vrana.cz/vytvoreni-pratelskeho-url.php
      static public function slugify($text)
      {
      // replace non letter or digits by -
      $text = preg_replace('~[^\\pL\d]+~u', '-', $text);

      // trim
      $text = trim($text, '-');

      // transliterate
      if (function_exists('iconv'))
      {
      $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
      }

      // lowercase
      $text = strtolower($text);

      // remove unwanted characters
      $text = preg_replace('~[^-\w]+~', '', $text);

      if (empty($text))
      {
      return 'n-a';
      }

      return $text;
      }


      You might want to check that and correct properly not replacing the non-utf-8.

      Attached Image

    • 03/01/10 6:45pm

      Gert Findel says:

      sorry for the repeated posting =(
      Please delete if possible

  • avatar
    Last edited:
    03/02/10
    3:32am
    Taboubi Issam says:

    all:
    propel:
    class: sfPropelDatabase
    param:
    dsn: mysqli://root:@localhost/databasename
    encoding: utf8

    make sure tp put enconding utf8 in your databases.yml

    Previous versions of this answer: 03/02/10 at 3:33am

  • avatar
    Last edited:
    03/02/10
    11:00am
    Nirav Ranpara says:

    Hi Lawrence,

    For Turkish character support you just need to follow bellow steps.

    [1] You need to execute bellow query after open mysql connection.

    "SET NAMES utf8"

    OR

    In symfony you need to put

    encoding: utf8

    in database.yml

    [2] COLLATE=utf8_unicode_ci for specific fields in which you want to store Turkish or any character.

    That's it.

    I tested it and it working properly.

    For any query please ask to me.

    Regards
    - Nirav Ranpara

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.