How to prevent the display of the question symbol character, even using mb_substr and utf-8

I read several other questions, tried the answers, but did not get the result at the end. What I get, for example, is

Μήπως θα έπρεπε να   ... 

and I cannot remove this strange question mark. I do this to get the contents of an RSS feed, which is also encoded <?xml version="1.0" encoding="UTF-8"?> , Using Greek for the content.

Is there any way to fix this?

 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <div><?php $entry->description = strip_tags($entry->description); echo mb_substr($entry->description, 0, 490); ?> ...</div> 
+7
source share
3 answers

This is the answer

 mb_substr($entry->description, 0, 490, "UTF-8"); 
+17
source

I believe the problem is with your encoding. The output is UTF-8, but your browser cannot interpret one of the characters. The question mark symbol, as I knew it in the past, is actually generated by the browser, so there is no search and replacement ... it is about fixing your encoding OR removing unknown characters from the string before its output ...

If you have access to the data source, you can check the database settings to make sure it is encoded correctly ... if not, then you will have to find a way to convert the data using php ... not an easy task ...

May be:

 mb_convert_encoding($string, "UTF-8"); 
+12
source

Have you tried to use these seemingly redundant multibyte safe string functions that are not in the php core?

http://code.google.com/p/mbfunctions/

It looks like they are offering the mb_strip_tags () function, such as:

 if (! function_exists('mb_strip_tags')) { function mb_strip_tags($document,$repl = ''){ $search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments including CDATA ); $text = mb_preg_replace($search, $repl, $document); return $text; } } 
0
source

All Articles