theimmortalbg Posted December 13, 2010 Share Posted December 13, 2010 hello i have problem with reading utf-8 text from normal text file with utf8 encoding. I am bulgarian i want to read and write bulgarian text but i cant. $fh = fopen("pics/names.txt", 'r'); $theData = fread($fh, 5); fclose($fh); echo $theData; This is what i use. Iam with windows 7. Pls help me... Quote Link to comment Share on other sites More sharing options...
nafetski Posted December 13, 2010 Share Posted December 13, 2010 You need to tell the browser (via meta tag) that you're using UTF-8. Should fix your prob! Quote Link to comment Share on other sites More sharing options...
theimmortalbg Posted December 13, 2010 Author Share Posted December 13, 2010 i hava that tag <meta content="text/html" charset="utf-8" /> in the php file and i dont want to have tags in clear text txt file from which i read Quote Link to comment Share on other sites More sharing options...
nafetski Posted December 13, 2010 Share Posted December 13, 2010 Hrmn, what does your output look like? Most encoding issues stem from the fact that the file (or database table) isn't in UTF-8, or the browser isn't rendering it as UTF-8. Quote Link to comment Share on other sites More sharing options...
theimmortalbg Posted December 14, 2010 Author Share Posted December 14, 2010 ��� this is the output Quote Link to comment Share on other sites More sharing options...
theimmortalbg Posted December 14, 2010 Author Share Posted December 14, 2010 i check charset is utf-8 with mb_detect_encoding() function and i know it because i use notepad++ for opening the txt file and I set it from there in utf-8 without BOM Quote Link to comment Share on other sites More sharing options...
nafetski Posted December 14, 2010 Share Posted December 14, 2010 Alright, next step would be put a character that you know is just utf-8 and echo it out. If that works, then it's a file problem. If it doesn't, it's either a config or browser issue Quote Link to comment Share on other sites More sharing options...
theimmortalbg Posted December 14, 2010 Author Share Posted December 14, 2010 it works when echo something in bulgarian but dont work from file ... what i shoud do it must have any way Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.