0

Hi I'm having some difficulty with escaping double quoutes from a string.

Here's my situation:
I get the the result set from the database then I apply utf8_encode to it because there's latin/accented characters and it return the string as it should be exept the double quotes in the begin and end of the string.

If in the DB I have: "Olá João" it returns: Olá João. The double quotes are ignored

$rs   = mysql_fetch_array($query)
$text = utf8_encode($rs['l_reference']);
echo $text;

I tried using addslashes but without success.

hakre
  • 193,403
  • 52
  • 435
  • 836
saomi
  • 855
  • 5
  • 16
  • 38
  • Please provide a `var_dump` of both the array entry as well as of `$text`. And [a hexdump of both these two strings](http://stackoverflow.com/q/1057572/367456), too. I'm not really sure if these quotes are actually in the database or not I must say. – hakre Dec 27 '12 at 10:25
  • Thanks @hakre. Here's a small the initial part of the var_dump of text: string(705) " O primeiro.... there's the double quotes in the begining. But it doesn't appear in the echo – saomi Dec 27 '12 at 10:32

1 Answers1

0

I think its because "Olá João" is a multibyte string and you must use a different workaround for this. Try this one mb_addslashes

Netorica
  • 18,523
  • 17
  • 73
  • 108
  • 1
    Well it is a multibyte string, because it has more than one byte. I never need to use any workarounds for strings with multiple bytes, so makes not really sense to me. – hakre Dec 27 '12 at 10:25
  • @hakre thank you, well I know only that is multibyte is Japanese encoding hehe – Netorica Dec 27 '12 at 10:26
  • It's just a small difference: What you mean is a multi-byte (octet) encoding - but not string. A multi-byte string must not carry data in a multi-byte encoding. – hakre Dec 27 '12 at 10:27
  • @hakre thank you for the info, i'm now currently reading about it – Netorica Dec 27 '12 at 10:29