Jump to content
php.lv forumi

Teksta formatesana


bublik

Recommended Posts

$find = array("Ā","Ē","Ū","Ī","Š","Ģ","Ķ","Ļ","Ž","Č","Ņ","ā","ē","ū","ī","š","ģ","ķ","ļ","ž","č","ņ");
$replace = array("A","E","U","I","S","G","K","L","Z","C","N","a","e","u","i","s","g","k","l","z","c","n");
$text=str_ireplace($find,$replace,$text);

 

Vai ir pareizi uzrakstits ? jo vins isti nestrada?

Link to comment
Share on other sites

Tagad vins strada, bet ir velviena problema... vins tekstu kuru parveidot nem no MySql tabulas kodejums - (utf8_general_ci), un ja es tagad izveidoju

$find = array("Ā","Ē","Ū","Ī","Š","Ģ","Ķ","Ļ","Ž","Č","Ņ","ā","ē","ū","ī","š","ģ","ķ","ļ","ž","č","ņ");
$replace = array("A","E","U","I","S","G","K","L","Z","C","N","a","e","u","i","s","g","k","l","z","c","n");
$text=str_place($find,$replace,$text);

 

Un vins neatpazist si kodejuma garumzimes , un nenomaina tas!

Vai ir kadi ieteikumi ??

Link to comment
Share on other sites

Kā nobrūk ?

 

Enīvei, ja tev ir svarīgi, lai viss pārējais skripts paliek ANSI, tad vari tos divus masīvos ievietot atsevišķā failā, ko pieseivo kā utf-8, un iekļauj iekš tā faila, kur reāli vajag to aizvietošanu. Un failu pieseivo utf-8 bez DOM.

 

Var arī tos masīvus pirms izmantošanas izlaist caur iconv un pārkonvertēt uz utf-8.

Link to comment
Share on other sites

Enīvei, ja tev ir svarīgi, lai viss pārējais skripts paliek ANSI, tad vari tos divus masīvos ievietot atsevišķā failā, ko pieseivo kā utf-8, un iekļauj iekš tā faila, kur reāli vajag to aizvietošanu. Un failu pieseivo utf-8 bez DOM.

 

ko tas DOM dod/nedod?

Edited by ray
Link to comment
Share on other sites

Vispār jau es pārteicos - bija domāts BOM jeb Byte Order Mask. Tā ir tāda fiška, kas vajadzīga specifiskiem Unicode formātiem (piem., UTF-16, UTF-32 u.c., ja nemaldos), lai tie pareizi strādātu. Nepateikšu gan īsti, ko viņs dara, jo nezinu :). Bet katrā ziņā zinu, ka UTF-8 formātam tas BOM nav vajadzīgs.

 

Reāli BOM ir daži "neredzami" simboli faila sākumā. Un viņi parasti traucē, jo browseri nez kāpēc nemāk ar viņiem appieties. Tas sajauc tiem galvu. Tāpēc to vajag izravēt.

Link to comment
Share on other sites

  • 3 weeks later...
×
×
  • Create New...