As I have already commented, it seems likely to be some conversion of ASCII quotes into some Brazilian, maybe Wordpress itself is converting at the time of saving, turning into “
(U+201C) when quotation marks ("
) go left and ”
(U+201D) when they are to the right of some text
Note that although similar to the ASCII table they are not the same Codepoint. Your PHP page must be in iso-8859-1 or windows-1252 (both assumed by apache or browser), or if your PHP is even in UTF-8 then it means that these characters are not traditional quotes, but quotes created by the WP class itself to use their own codepoints and emojis.
I won’t claim that this is the best solution, but as it is working with another bank and not with the Wordpress API directly (maybe it itself provides something that "decodes" what they themselves have done) the iconv
(needs to be libiconv, most PHP servers have - are "compiled" with this):
<?php
$exemplo = '“Cavalo dado não se olha os dentes”, disse a professora
Segunda linha';
$exemplo = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $exemplo);
$texto = nl2br($exemplo);
echo $texto;
another interim solution would be str_replace
(you’ll probably have to use utf8_decode
), thus:
<?php
$exemplo = '“Cavalo dado não se olha os dentes”, disse a professora
Segunda linha';
$exemplo = str_replace(array('“', '”'), '"', $exemplo);
$texto = nl2br($exemplo);
echo $texto;
Remember that the PHP document that uses this will have to be saved in "Utf-8 without BOM".
You can also start using header('Content-Type: text/html; charset=utf-8')
, but that really only if you wish and of course the quotation marks there will still be the Unicodes “
(U+201C) and ”
(U+201D)
Dear Caio, this face that this are not quotes, at least not quotes from ASCII, can be a UNICODE, can be coding error page, may have been problem in INSERT (I believe the most likely);
– Guilherme Nascimento
@Guilhermenascimento thanks for the help. These data came from a database in Wordpress, I’m accessing the post table of Wordpress. Really if I edit the content and recollect the Apas, it appears. What can it be? And how to solve?
– caiocafardo
It seems to me likely to be some conversion of the ASCII quotes into some Brazilian, maybe the WP itself is converting at the time of saving, turning into
“
(U+201C
) when quotation marks"
go left and”
(U+201D
)... Note that although similar to the ASCII table they are not the same Codepoint. Your PHP page must be in iso-8859-1 or windows-1252 (both assumed by apache or browser), or if your PHP is even in UTF-8 then it means that these characters are not traditional quotes, but quotes created by the WP class itself to use codepoints and emojis themselves.– Guilherme Nascimento
It’s really these quotes. It’s all in UTF-8. But do you see any around it? Because I need to list over 7000 texts, and many are like this...
– caiocafardo