teobalds Posted April 28, 2009 Report Posted April 28, 2009 Labdien! Mani interesē, vai pastāv iespēja, tekstu, kas ir latviešu valodā pārveidot uz standarta latīņu alfabēta tekstu - tipa vai nu izņemt burtus, kuros ir garumzīmes / mīkstinājuma zīmes vispār ārā, vai noņemt garumzīmi/ mīkstinājuma zīmi. Mēģināju to panākt ar šādu funkciju, taču aplauzos - tas laikam nav īstais ... :( <?php function charset_decode_utf_8($string) { if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string)) return $string; $string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e", "''.((ord('\\1')-224)*4096 + (ord('\\2')-128)*64 + (ord('\\3')-128)).';'", $string); $string = preg_replace("/([\300-\337])([\200-\277])/e", "''.((ord('\\1')-192)*64+(ord('\\2')-128)).';'", $string); return $string; } ?> Vai kāds ir kautko tamlīdzīgu taisījis? Quote
Morphius Posted April 28, 2009 Report Posted April 28, 2009 Negribu lieki izcelties...bet kam tas vajadzīgs? :) Quote
xPtv45z Posted April 28, 2009 Report Posted April 28, 2009 (edited) echo iconv('UTF-8','ASCII//TRANSLIT','glāžšķūņu rūķīši');// izvada - glazskunu rukisi Protams, ja teksts ir utf8 Edited April 28, 2009 by xPtv45z Quote
bubu Posted April 28, 2009 Report Posted April 28, 2009 To vajag darīt ar parastu str_replace vai strtr. Saraksti masīvu ar ko uz ko konvertēt ("ā" => "a", "č" => "č", utt) un izsauc attiecīgo fju. Quote
web-dev.lv Posted April 29, 2009 Report Posted April 29, 2009 sliņķiem RU & LV function translitString($str) { $str = str_replace(array('й','ц','у','к','е','н','г','ш','щ','з','х','ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я','ч','с','м','и','т','ь','б','ю','Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь','Б','Ю','Ā','Č','Ē','Ģ','Ī','Ķ','Ļ','Ņ','Š','Ū','Ž', 'ā','č','ē','ģ','ī','ķ','ļ','ņ','š','ū','ž'),array('A','C','E','G','I','K','L','N','S','U','Z','a','c','e','g','i','k','l','n','s','u','z','i','c','u','k','e','n','g','sh','sh','z','h','i','f','i','v','a','p','r','o','l','d','zh','e','ja','ch','s','m','i','t','','b','ju','I','C','U','K','E','N','G','SH','SH','Z','H','I','F','I','V','A','P','R','O','L','D','ZH','E','JA','CH','S','M','I','T','','B','JU','A','C','E','G','I','K','L','N','S','U','Z','a','c','e','g','i','k','l','n','s','u','z'),$str); return $str; } Quote
crmind Posted May 18, 2009 Report Posted May 18, 2009 Izmantoju šo - http://paste.php.lv/b283c7be0f97f03ec1bb27...e9d6df?lang=php Quote
Ranny Posted May 19, 2009 Report Posted May 19, 2009 (edited) Sadarbojoties ar citvalodīgajiem, nākas sūtīt viņiem datu failus kuros ir Latvijas adreses un kuros drīkst būt tikai latīņu burti un vēl nedrīkst būt specsimboli, tad nu izmantoju: $LATV=array("ā","Ā","č","Č","ē","Ē","ģ","Ģ","ī","Ī","ķ","Ķ","ļ","Ļ","ņ","Ņ","š","Š","ū","Ū","ž","Ž",".",'"'," ","-","_","/"); //Latviešu garie un mīkste burti un neatļautie simboli $LATIN=array("a","A","c","C","e","E","g","G","i","I","k","K","l","L","n","N","s","S","u","U","z","Z","",""," ",""," "," "); //Latviešu mīksto un garo burtu un neatļauto simbolu aizstāēji $IELA_LATIN=str_replace($LATV,$LATIN,$IELA_LATV); //Latviešu garos un mīkstos burtus aizstāj ar latīņu burtiem Edited May 19, 2009 by Ranny Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.