This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » [solved] iconv cyrillic (russian)
[solved] iconv cyrillic (russian) [message #75364] Sat, 21 March 2009 21:29 Go to next message
BabySnake  is currently offline BabySnake
Messages: 81
Registered: March 2008
Location: Sweden
Member

Hi!

Im trying the iconv function which is used in jobeet in the slugify function for removing accents etc. This I can also do. The problem I'm having occurs when I try to convert cyrillic/russian characters to us-ascii/TRANSLIT (i.e трактор => traktor). This results in a bunch of questionmarks. I even tried it from the shell with the same results. I'm on Ubuntu 8.10 by the way, I installed russian language on it. Did anyone outhere get it to work with cyrillic/russian characters?

best regards!

[Updated on: Sun, 09 May 2010 20:57]

Re: [OT] iconv cyrillic (russian) [message #98769 is a reply to message #75364 ] Sun, 09 May 2010 20:56 Go to previous message
BabySnake  is currently offline BabySnake
Messages: 81
Registered: March 2008
Location: Sweden
Member

I decided to skip the iconv program... There are easier ways to transfer cyrillic to latin.. just see the example below:

class Cyrillic2LatinConverter
{
 public static function convert($russian_string)
  {
    $table = array(
                'А' => 'A',
                'Б' => 'B',
                'В' => 'V',
                'Г' => 'G',
                'Д' => 'D',
                'Е' => 'E',
                'Ё' => 'YO',
                'Ж' => 'ZH',
                'З' => 'Z',
                'И' => 'I',
                'Й' => 'J',
                'К' => 'K',
                'Л' => 'L',
                'М' => 'M',
		'Н' => 'N',
                'О' => 'O',
                'П' => 'P',
                'Р' => 'R',
                'С' => 'S',
                'Т' => 'T',
                'У' => 'U',
                'Ф' => 'F',
                'Х' => 'H',
                'Ц' => 'C',
                'Ч' => 'CH',
                'Ш' => 'SH',
                'Щ' => 'CSH',
                'Ь' => '',
                'Ы' => 'Y',
                'Ъ' => '',
                'Э' => 'E',
                'Ю' => 'YU',
                'Я' => 'YA',
             
                'а' => 'a',
                'б' => 'b',
                'в' => 'v',
                'г' => 'g',
                'д' => 'd',
                'е' => 'e',
                'ё' => 'yo',
                'ж' => 'zh',
                'з' => 'z',
                'и' => 'i',
                'й' => 'j',
                'к' => 'k',
                'л' => 'l',
                'м' => 'm',
                'н' => 'n',
                'о' => 'o',
                'п' => 'p',
                'р' => 'r',
                'с' => 's',
                'т' => 't',
                'у' => 'u',
                'ф' => 'f',
                'х' => 'h',
                'ц' => 'c',
                'ч' => 'ch',
                'ш' => 'sh',
                'щ' => 'csh',
                'ь' => '',
                'ы' => 'y',
                'ъ' => '',
                'э' => 'e',
                'ю' => 'yu',
                'я' => 'ya',
    );

    $latin_string = str_replace(
        array_keys($table),
        array_values($table),$russian_string
    );

    

    return $latin_string;
  }

}
Previous Topic:Symfony Users in Vancouver BC Canada
Next Topic:admin gen module & I18N fields -> sF tries to save Object's Translation before Object...!
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software