Jump to content
php.lv forumi

Kaut kāds murgs ar encoding


bobsters

Recommended Posts

Ir tāda lieta - no datubāzes izvelkot datus (ar mīkstinājumiem) viņi netiek pareizi uzrādīti!

Ja noņem pašas lapas kodējumu -

 

<meta http-equiv = "Content-Type" content = "text/html; charset=UTF-8"/>

 

vai

 

header('Content-type:text/html; charset=UTF-8');

 

tad lapā jau ierakstīto informāciju rāda pareizi latviešu kodējumā! bet no datu bāzes izvilktos nepareizi

 

Kad ieslēdz

header();

tad rāda pareizi izvadīto informāciju no datubāzes bet nepareizi burtus pašā lapā. Kur ir problēma.

 

Datubāzē ir uzstādīts

SET names UTF8;

Link to comment
Share on other sites

+ vēl uzpeldēja viena problēma!

kad pievieno tekstu ar garumzimem datubāzei caur php skriptu izmet erroru

Incorrect string value: '\x81' for column 'title' at row 1

 

bet kad pievieno bez garumzimem tad viss kartiba!

 

 

P.s. atradu kļūdu! Kad saglabāju failu nebiju ievērojis ka enkodējums bija windows-127! tāpēc arī bija tā nesakritība.

Edited by bobsters
Link to comment
Share on other sites

Izvadot $replace ir ascii pārbaudīju to ar mb_detect_encoding() formātā!

 

Mēģināju ar mb_convert_encoding() funkciju, bet viņš atmet to simbolu kurš tiek pārvērsts no ASCII uz UTF-8

 

 

 


function fixlink($title){

   $characters=array("ā","č","ē","ģ","ī","ķ","ļ","ņ","š","ū","ž"," ");


   $replace=array("a","c","e","g","i","k","l","n","s","u","z","");
   return str_replace($characters2,$replace,strtolower($title));


} 

Link to comment
Share on other sites

Izvadot $replace ir ascii pārbaudīju to ar mb_detect_encoding() formātā!

 

Mēģināju ar mb_convert_encoding() funkciju, bet viņš atmet to simbolu kurš tiek pārvērsts no ASCII uz UTF-8

 

 

 


function fixlink($title){

   $characters=array("ā","č","ē","ģ","ī","ķ","ļ","ņ","š","ū","ž"," ");


   $replace=array("a","c","e","g","i","k","l","n","s","u","z","");
   return str_replace($characters2,$replace,strtolower($title));


} 

 

Bet kādēļ tas ir jāmoka ar dažādām funkcijām utml. ja to var panākt izveidojot kārtīgi un pareizi saglabājot visu uz UTF-8?

 

Tu tiešām zini ka visu izmēģināji, t.i. arī saglabāšanu un DB veida maiņu(charset)?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...