[dx] Posted September 4, 2009 Report Share Posted September 4, 2009 (edited) 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']); Edited September 4, 2009 by Haris S Link to comment Share on other sites More sharing options...
Ingolme Posted September 4, 2009 Report 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 Report 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 Report 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 Report 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 Report Share Posted September 6, 2009 Any help? Link to comment Share on other sites More sharing options...
dsonesuk Posted September 6, 2009 Report Share Posted September 6, 2009 (edited) try using:mysql_query("SET NAMES 'utf8'");this will read and display the correct character, without using replace. Edited September 6, 2009 by dsonesuk Link to comment Share on other sites More sharing options...
[dx] Posted September 6, 2009 Author Report 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 Report 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 Report 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
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now