[dx] Posted September 4, 2009 Share Posted September 4, 2009 Hi, I'm getting problem when trying replace these chars. It wont work, but there are no any error message or something like that. $find = array('č', 'ć', 'š', 'đ', 'ž');$replace = array('č', 'ć', 'š', 'đ', 'ž'); (these chars are in ASCII, but on forum shown on other way ex. č)$index['body'] = str_replace($find, $replace, $index['body']); Link to comment Share on other sites More sharing options...
Ingolme Posted September 4, 2009 Share Posted September 4, 2009 It might be that the PHP file isn't saved with the correct character set. Link to comment Share on other sites More sharing options...
[dx] Posted September 4, 2009 Author Share Posted September 4, 2009 It's strange.I have SMF forum installed, and one script which uses data from SMF's database. Everything is well, but char č ć and đ are shown as " ? "I'm using thisheader("Content-Type: text/html; charset=Windows-1250");Also tried UTF-8 and ISO-8859-1 Link to comment Share on other sites More sharing options...
justsomeguy Posted September 4, 2009 Share Posted September 4, 2009 Go into the database and check what's in the tables. See if the tables actually contain "?" or if they contain the original character. Link to comment Share on other sites More sharing options...
[dx] Posted September 4, 2009 Author Share Posted September 4, 2009 Already check, it's č Link to comment Share on other sites More sharing options...
[dx] Posted September 6, 2009 Author Share Posted September 6, 2009 Any help? Link to comment Share on other sites More sharing options...
dsonesuk Posted September 6, 2009 Share Posted September 6, 2009 try using:mysql_query("SET NAMES 'utf8'");this will read and display the correct character, without using replace. Link to comment Share on other sites More sharing options...
[dx] Posted September 6, 2009 Author Share Posted September 6, 2009 Now getting this for char čÄŤStrange Link to comment Share on other sites More sharing options...
Ingolme Posted September 6, 2009 Share Posted September 6, 2009 Now getting this for char čÄŤStrangeThat's good. Now, if you give your page a UTF-8 encoding it will display correctly.Try adding this to your page (before anything else):<?php header("Content-type: text/html;charset=UTF-8"); ?> Link to comment Share on other sites More sharing options...
[dx] Posted September 7, 2009 Author Share Posted September 7, 2009 Oh Thank you! You're the best :) Thank you again Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.