Re: zamena znaku s diakritikou-PHP

From: Laddobar (laddobar@volny.cz)
Date: 06. 12. 2001, 21:35 CET


Tady je jeste nerizikova varianta odkudsi:

$win2asc=array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,
 61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
 81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,
 101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,
 116,117,118,119,120,121,122,123,124,125,126,127,32,32,44,34,
 32,32,32,32,32,37,83,174,83,84,90,90,39,39,34,34,254,45,45,
 32,32,32,115,175,115,116,122,122,32,32,32,76,32,65,124,35,32,
 32,83,174,191,45,32,90,248,241,32,108,44,230,249,250,32,97,
 115,175,76,32,108,122,82,65,65,65,142,76,67,67,67,69,69,69,69,
 73,73,68,68,78,78,79,79,79,153,32,82,85,85,85,154,89,84,225,
 114,97,97,97,132,108,99,99,99,101,101,101,101,105,108,100,100,
 110,110,111,111,111,148,246,114,117,117,117,129,121,116,255);

function Win2Ascii($str) {
 $str=StrTr($str,"\xA9\xAB\xAE\xB9\xBB\xBE","\x8A\x8D\x8E\x9A\x9D\x9E");
 global $win2asc;
 for ($i=0; $i<strlen($str); $i++)
         {
         $str[$i]=chr($win2asc[ord($str[$i])]);
         }
 return $str;
}


Pouziti stejne, tj. $asciitext=Win2Ascii($textshacky);

S pozdravem Ladislav Pelcl - Laddobar
--
---< Welcome to the Desert of the Real.. >---
---< E-mail >---< ladislav@pelcl.cz >---< laddobar@volny.cz >---
---< ICQ # >---< 36366729 >---
---< Web >---< http://laddobar.pelcl.cz/ >---

At se s tim nemusite psat:

function odhackuj($mystring) {
  return
StrTr($mystring,"áéíóúùýäëöüìÁÉÍÓÚÙÝÄËÖÜÌèïòø¹»¾ÈÏÒØ©«®","aeiouuyaeoueAE
IOUUYAEOUEcdnrstzCDNRSTZ");
}

Pouziti:

$odhackovano=odhackuj("retezec s diakritikou");

Vyzkouseno na vete s moc zlutym konem.
Jestli jsem na nejaky znak zapomnel, omlouvam se - stejne tak se
omlouvam za diakritiku, ktera je v tomto pripade bohuzel nutna.
Pokud to nekdo dostanete zmrsene a chcete to pouzit, mohu zaslat
soukrome jako prilohu v libovolnem 8mi bit. kodovani.
Martin



This archive was generated by hypermail 2.1.2 : 06. 12. 2001, 21:57 CET