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... Link to comment https://forums.phpfreaks.com/topic/221560-php-utf8-encoding/ 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! Link to comment https://forums.phpfreaks.com/topic/221560-php-utf8-encoding/#findComment-1146903 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 Link to comment https://forums.phpfreaks.com/topic/221560-php-utf8-encoding/#findComment-1146923 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. Link to comment https://forums.phpfreaks.com/topic/221560-php-utf8-encoding/#findComment-1146936 Share on other sites More sharing options...
theimmortalbg Posted December 14, 2010 Author Share Posted December 14, 2010 ��� this is the output Link to comment https://forums.phpfreaks.com/topic/221560-php-utf8-encoding/#findComment-1146949 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 Link to comment https://forums.phpfreaks.com/topic/221560-php-utf8-encoding/#findComment-1146951 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 Link to comment https://forums.phpfreaks.com/topic/221560-php-utf8-encoding/#findComment-1146954 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 Link to comment https://forums.phpfreaks.com/topic/221560-php-utf8-encoding/#findComment-1146972 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.