Rich Bitch Posted May 28, 2008 Report Share Posted May 28, 2008 vai ir kaada funkcija, kas tekstu lv paartaisa par tekstu ar latiinu burtiem? Piem. LV:Šodien ir skaista diena. LATIN: Sodien ir skaista diena. Esmu redzeejis, ka daudzi taa veido url (piem. worpress), kur virsrakstu kaadam ierakstam paartaisa par url un man to pashu savajadzeejaas. Link to comment Share on other sites More sharing options...
Aleksejs Posted May 28, 2008 Report Share Posted May 28, 2008 Gatava nav, bet pameklē - tepat forumā jābūt realizācijai. Link to comment Share on other sites More sharing options...
Rich Bitch Posted May 28, 2008 Author Report Share Posted May 28, 2008 tad veel man ir shaads regexp preg_replace("/[^a-zA-Z0-9s]/", "", $teksts); man it kaa vajadzeetu nonjemt visus non-alphanumeric simbolus un atstaat atstarpes, bet viņsh man kkaa atstarpes ar neatstaaj :/ Link to comment Share on other sites More sharing options...
andrisp Posted May 28, 2008 Report Share Posted May 28, 2008 s vietā vajag \s. Link to comment Share on other sites More sharing options...
Vebers Posted May 28, 2008 Report Share Posted May 28, 2008 Ja ir pieejams iconv modulis, tad tas ir pavisam vienkārši setlocale(LC_ALL, 'en_US.UTF8'); function clearUTF($s) { $r = ''; $s1 = iconv('UTF-8', 'ASCII//TRANSLIT', $s); for ($i = 0; $i < strlen($s1); $i++) { $ch1 = $s1[$i]; $ch2 = mb_substr($s, $i, 1); $r .= $ch1=='?'?$ch2:$ch1; } return $r; } echo clearUTF('Šíleně žluťoučký Vašek úpěl olol! This will remain untranslated: ķūlīš :)) hahaha '); setLocale ir obligāti jāizsauc. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted May 28, 2008 Report Share Posted May 28, 2008 uzraksti savu f-ju ;) tev tik vajadzees kodu tabulu un $kodejums[0]='@[ā]@mu'; $dekodejums[0]='a'; $kodejums[1]='@[Ā]@mu'; $dekodejums[1]='A'; $kodejums[2]='@[č]@mu'; $dekodejums[2]='c'; ...... $strings=preg_replace($kodejums,$dekodejums,$strings); // nomaina uz latinju burtiem un tas arii viss... Link to comment Share on other sites More sharing options...
andrisp Posted May 28, 2008 Report Share Posted May 28, 2008 Grey_Wolf, priekš kam preg_replace ? Tas tak būs overkills, jo pietiek taču ar str_replace(). Link to comment Share on other sites More sharing options...
marrtins Posted May 28, 2008 Report Share Posted May 28, 2008 O, tas ar iconv baisi elegants variants. Link to comment Share on other sites More sharing options...
marcis Posted May 29, 2008 Report Share Posted May 29, 2008 es reku šitādu izmantoju function generate_title($title){ $title=strtolower($title); $chars=array("ā"=>"a","č"=>"c","ē"=>"e","ģ"=>"g","ī"=>"i","ķ"=>"k","ļ"=>"l","ņ"=>"n","š"=>"s","ū"=>"u","ž"=>"z","-"=>"_"," "=>"_",); foreach($chars as $key=>$value){ $title=str_replace($key,$value,$title); } $title=ereg_replace("[^a-z0-9_]","",$title); return $title; } Link to comment Share on other sites More sharing options...
marrtins Posted May 29, 2008 Report Share Posted May 29, 2008 Grey_Wolf, priekš kam preg_replace ? Tas tak būs overkills, jo pietiek taču ar str_replace(). Btw, sakompilētie preg patterni paliek kešā, tākā uz apache+mod_php vēl vajadzētu patestēt, lai būtu skaidra bilde. Kādam nav *elegants* variants, lai arī rus čarus pārvērstu par latīņu? Ja nav, derēs arī ar replac`iem :) Link to comment Share on other sites More sharing options...
andrisp Posted May 29, 2008 Report Share Posted May 29, 2008 Man bija šitāds: http://paste.php.lv/7465?lang=php Link to comment Share on other sites More sharing options...
bubu Posted May 29, 2008 Report Share Posted May 29, 2008 iconv + //TRANSLIT ? Link to comment Share on other sites More sharing options...
andrisp Posted May 29, 2008 Report Share Posted May 29, 2008 Es vienreiz mēģināju ar iconv+translit, bet kaut kas tur negāja. Man liekas, ka RU simboli īsti labi nekonvertējas. Link to comment Share on other sites More sharing options...
marrtins Posted May 29, 2008 Report Share Posted May 29, 2008 bubu, man čota arī neizdevās piešķilt iconv/translit ar rus (utf8) andrisp, thnx Link to comment Share on other sites More sharing options...
Recommended Posts