pouzivam free webhosting ic.cz tak ak by niekto vedel ktore kodovanie si mam vybrat tak mu budem velmi vdacny
Vyber kodovania pre DB
-
xivo
Light Professional
- Príspevky: 752
- Registrovaný: 27 jún 2005, 22:49
- Bydlisko: Slovensko
- Kontaktovať používateľa:
Vyber kodovania pre DB
Mam mensi problem, kamosovi robim www a stale mi namiesto "č","š" ... hadze "?", Na stranke mam spravne nastavene charset=Windows-1250 takze sa jedna o db z ktorej taham texty a pre nu som uz skusil hadam vsetky v ktorych sa nachadzalo "sk" ale stale nic ...
pouzivam free webhosting ic.cz tak ak by niekto vedel ktore kodovanie si mam vybrat tak mu budem velmi vdacny
pouzivam free webhosting ic.cz tak ak by niekto vedel ktore kodovanie si mam vybrat tak mu budem velmi vdacny
-
masterdead
SysAdmin
- Príspevky: 1809
- Registrovaný: 03 aug 2005, 23:32
- Bydlisko: Bratislava
- Kontaktovať používateľa:
-
mastermind
VIP
- Príspevky: 4810
- Registrovaný: 09 feb 2005, 13:17
Veľmi často je nastavené, aby MySQL ukladal dáta v utf-8 kódovaní. Aby si mohol pracovať aj s inými znakovými sadami, musíš MySQL povedať, v akej znakovej sade jej tie údaje posielaš a v akej ich chceš dostávať naspäť.
Skús pridať niečo ako (za otvorenie databázy): (alebo by sa dalo zmeniť predvolené kódovanie databázy)
Skús pridať niečo ako (za otvorenie databázy):
Kód: Vybrať všetko
mysql_query("SET CHARACTER SET 'cp1250'", $link);To je pre to, že IE na štandardy kašle.xivo napísal:sorry chrono ale moc som z toho nechytil, lebo problem mi nerobi IE ale Firefox
//chrono: Tak nie. V html hlavičke máš nastavenú nesprávnu znakovú sadu. Má tam byť iba UTF-8 a nie UTF_8_slovak_ci
nemas pravdu .. v phpMyAdminovi sa tiez nastavuje kodovanie DB ..hojko napísal:xivo: To co pises nie je kodovanie MySQL databaze, je to len pre PhpMyAdmin a nepomoze ti to. Kodovanie zmenis jedine cez konzolu MySQL na strane servera.
ako uz bolo spomenute vyssie .. nastav si vystup z DB na potrebnu znakovu sadu na zaciatku skriptu (najlepsie hned po pripojeni k DB) cez
SET CHARACTER SET ...
ja som sa vybodol na vsetky tieto kodovania a spravil som si funkciu s ktorou som nemal este problem. takze tu je iste riesenie
Kód: Vybrať všetko
function diakritika($textpop)
{
$textpop=ereg_replace("á", "=:ad:=", $textpop);
$textpop=ereg_replace("ä", "=:ab:=", $textpop);
$textpop=ereg_replace("ć", "=:cd:=", $textpop);
$textpop=ereg_replace("č", "=:cm:=", $textpop);
$textpop=ereg_replace("ď", "=:dm:=", $textpop);
$textpop=ereg_replace("é", "=:ed:=", $textpop);
$textpop=ereg_replace("ě", "=:em:=", $textpop);
$textpop=ereg_replace("í", "=:id:=", $textpop);
$textpop=ereg_replace("ĺ", "=:ld:=", $textpop);
$textpop=ereg_replace("ľ", "=:lm:=", $textpop);
$textpop=ereg_replace("ň", "=:nm:=", $textpop);
$textpop=ereg_replace("ó", "=:od:=", $textpop);
$textpop=ereg_replace("ő", "=:ob:=", $textpop);
$textpop=ereg_replace("ô", "=:ov:=", $textpop);
$textpop=ereg_replace("ŕ", "=:rd:=", $textpop);
$textpop=ereg_replace("ř", "=:rm:=", $textpop);
$textpop=ereg_replace("ś", "=:sd:=", $textpop);
$textpop=ereg_replace("š", "=:sm:=", $textpop);
$textpop=ereg_replace("ť", "=:tm:=", $textpop);
$textpop=ereg_replace("ú", "=:ud:=", $textpop);
$textpop=ereg_replace("ű", "=:ub:=", $textpop);
$textpop=ereg_replace("ů", "=:uo:=", $textpop);
$textpop=ereg_replace("ý", "=:yd:=", $textpop);
$textpop=ereg_replace("ź", "=:zd:=", $textpop);
$textpop=ereg_replace("ž", "=:zm:=", $textpop);
$textpop=ereg_replace("Á", "=:Ad:=", $textpop);
$textpop=ereg_replace("Ć", "=:Cd:=", $textpop);
$textpop=ereg_replace("Č", "=:Cm:=", $textpop);
$textpop=ereg_replace("Ď", "=:Dm:=", $textpop);
$textpop=ereg_replace("É", "=:Ed:=", $textpop);
$textpop=ereg_replace("Ě", "=:Em:=", $textpop);
$textpop=ereg_replace("Í", "=:Id:=", $textpop);
$textpop=ereg_replace("Ĺ", "=:Ld:=", $textpop);
$textpop=ereg_replace("Ľ", "=:Lm:=", $textpop);
$textpop=ereg_replace("Ň", "=:Nm:=", $textpop);
$textpop=ereg_replace("Ó", "=:Od:=", $textpop);
$textpop=ereg_replace("Ő", "=:Ob:=", $textpop);
$textpop=ereg_replace("Ô", "=:Ov:=", $textpop);
$textpop=ereg_replace("Ŕ", "=:Rd:=", $textpop);
$textpop=ereg_replace("Ř", "=:Rm:=", $textpop);
$textpop=ereg_replace("Ś", "=:Sd:=", $textpop);
$textpop=ereg_replace("Š", "=:Sm:=", $textpop);
$textpop=ereg_replace("Ť", "=:Tm:=", $textpop);
$textpop=ereg_replace("Ú", "=:Ud:=", $textpop);
$textpop=ereg_replace("Ű", "=:Ub:=", $textpop);
$textpop=ereg_replace("Ů", "=:Uo:=", $textpop);
$textpop=ereg_replace("Ý", "=:Yd:=", $textpop);
$textpop=ereg_replace("Ź", "=:Zd:=", $textpop);
$textpop=ereg_replace("Ž", "=:Zm:=", $textpop);
return $textpop;
}
function diakritikaspat($textpo)
{
$textpo=ereg_replace("=:ad:=", "á", $textpo);
$textpo=ereg_replace("=:ab:=", "ä", $textpo);
$textpo=ereg_replace("=:cd:=", "ć", $textpo);
$textpo=ereg_replace("=:cm:=", "č", $textpo);
$textpo=ereg_replace("=:dm:=", "ď", $textpo);
$textpo=ereg_replace("=:ed:=", "é", $textpo);
$textpo=ereg_replace("=:em:=", "ě", $textpo);
$textpo=ereg_replace("=:id:=", "í", $textpo);
$textpo=ereg_replace("=:ld:=", "ĺ", $textpo);
$textpo=ereg_replace("=:lm:=", "ľ", $textpo);
$textpo=ereg_replace("=:nm:=", "ň", $textpo);
$textpo=ereg_replace("=:od:=", "ó", $textpo);
$textpo=ereg_replace("=:ob:=", "ő", $textpo);
$textpo=ereg_replace("=:ov:=", "ô", $textpo);
$textpo=ereg_replace("=:rd:=", "ŕ", $textpo);
$textpo=ereg_replace("=:rm:=", "ř", $textpo);
$textpo=ereg_replace("=:sd:=", "ś", $textpo);
$textpo=ereg_replace("=:sm:=", "š", $textpo);
$textpo=ereg_replace("=:tm:=", "ť", $textpo);
$textpo=ereg_replace("=:ud:=", "ú", $textpo);
$textpo=ereg_replace("=:ub:=", "ű", $textpo);
$textpo=ereg_replace("=:uo:=", "ů", $textpo);
$textpo=ereg_replace("=:yd:=", "ý", $textpo);
$textpo=ereg_replace("=:zd:=", "ź", $textpo);
$textpo=ereg_replace("=:zm:=", "ž", $textpo);
$textpo=ereg_replace("=:Ad:=", "Á", $textpo);
$textpo=ereg_replace("=:Cd:=", "Ć", $textpo);
$textpo=ereg_replace("=:Cm:=", "Č", $textpo);
$textpo=ereg_replace("=:Dm:=", "Ď", $textpo);
$textpo=ereg_replace("=:Ed:=", "É", $textpo);
$textpo=ereg_replace("=:Em:=", "Ě", $textpo);
$textpo=ereg_replace("=:Id:=", "Í", $textpo);
$textpo=ereg_replace("=:Ld:=", "Ĺ", $textpo);
$textpo=ereg_replace("=:Lm:=", "Ľ", $textpo);
$textpo=ereg_replace("=:Nm:=", "Ň", $textpo);
$textpo=ereg_replace("=:Od:=", "Ó", $textpo);
$textpo=ereg_replace("=:Ob:=", "Ő", $textpo);
$textpo=ereg_replace("=:Ov:=", "Ô", $textpo);
$textpo=ereg_replace("=:Rd:=", "Ŕ", $textpo);
$textpo=ereg_replace("=:Rm:=", "Ř", $textpo);
$textpo=ereg_replace("=:Sd:=", "Ś", $textpo);
$textpo=ereg_replace("=:Sm:=", "Š", $textpo);
$textpo=ereg_replace("=:Tm:=", "Ť", $textpo);
$textpo=ereg_replace("=:Ud:=", "Ú", $textpo);
$textpo=ereg_replace("=:Ub:=", "Ű", $textpo);
$textpo=ereg_replace("=:Uo:=", "Ů", $textpo);
$textpo=ereg_replace("=:Yd:=", "Ý", $textpo);
$textpo=ereg_replace("=:Zd:=", "Ź", $textpo);
$textpo=ereg_replace("=:Zm:=", "Ž", $textpo);
$textpo=ereg_replace("=:r:=", "<br />", $textpo);
$textpo=ereg_replace("=:oz:=", "<p>", $textpo);
$textpo=ereg_replace("=:ok:=", "</p>", $textpo);
$textpo=ereg_replace("=:c:=", "<hr size=\"1\" color=\"navy\" width=\"100%\" />", $textpo);
$textpo=ereg_replace("=:hz:=", "<sup>", $textpo);
$textpo=ereg_replace("=:hk:=", "</sup>", $textpo);
$textpo=ereg_replace("=:dz:=", "<sub>", $textpo);
$textpo=ereg_replace("=:dk:=", "</sub>", $textpo);
$textpo=ereg_replace("=:tz:=", "<b>", $textpo);
$textpo=ereg_replace("=:tk:=", "</b>", $textpo);
$textpo=ereg_replace("=:kz:=", "<i>", $textpo);
$textpo=ereg_replace("=:kk:=", "</i>", $textpo);
$textpo=ereg_replace("=:pz:=", "<u>", $textpo);
$textpo=ereg_replace("=:pk:=", "</u>", $textpo);
return $textpo;
}-
mastermind
VIP
- Príspevky: 4810
- Registrovaný: 09 feb 2005, 13:17
To čo ukazuješ nie je nastavenie znakovej sady. To je iba na delenie slov. Tá stránka je v kódovaní windows-1250 a v html hlavičke máš UTF_8_slovak_ci. Keď to chceš mať v utf-8, musíš tam mať utf-8 a ešte musíš MySQL povedať, že to chceš v utf-8.xivo napísal:NO tak ked som to zmenil tak to bolo este horsie takze asi budem musiet este v db zmenit len na ktore ? ten UTF8_bin ?? alebo ...
Kód: Vybrať všetko
mysql_query("SET CHARACTER SET 'utf8'", $link);
mysql_query("SET COLLATION_CONNECTION='utf8_slovak_ci'", $link);z toho obrazka sa neda urcit co vlastne nastavujes ... ja len vravim ze sa cez to da nastavit aj kodovanie DB ... ostatne ako takmer vsetko co sa da cez konzolu ....hojko napísal:gwixt: Nemas pravdu, to co nastavujes v PhpMyAdminovi co vidis na obrazku nie je kodobanie db. Pokial ide o set character, tak myslim, ze tym databazu neprekonvertujes, ci sa mylim???
a tym set charakter set nekonvertujes DB ale len nastavis kodovanie vystupu
ereg_replace funguje inak ako str_replace. kedze ty vo svojom skripte nahradzas urcity string za iny, je samozrejmostou pouzit funkciu str_replace, ktora prechadza retazcom iba raz. funkcie, ktore spracovavaju regularne vyrazy, pouzivaju ovela komplikovanejsiu metodu hladania zhody a preto predlzuju cas vykonavania. preto takuto fciu pouzivaj iba v pripadoch pouzitia regularneho vyrazu, a nie na nahradenie jednoducheho retazca za retazec.turtlak69 napísal:nie som sice php guru ale tak neviem odkial si zobral ze toto je pomalsie ako npriklad str_replace. tym ta nechcem spochybnit, ale vypytat linkak bude rychlejsi sposob, tak rad pouzijem. myslim, ze na par textov co som mal (bezne pocty) to nebolo zle riesenie
taktiez nezabudaj, ze pri utf-8 su znaky s diakritikou povazovane za MultiByte String, a teda ked uz tak mb_ereg_replace
good luck.