From: "Jo�o C�ndido de Souza Neto" on
http://www.w3.org/TR/html4/charset.html

I hope it can help you.

PS: json_decode works only in utf8.

--
Jo�o C�ndido de Souza Neto

"Christoph Boget" <cboget(a)hotmail.com> escreveu na mensagem
news:AANLkTikPQDCkRQ7ctjwCCGspZ-C4fXPcnXXn_U48+1bZ(a)mail.gmail.com...
>> You should set the charset of your page by meta tag in its head.
>
> Do you have a source of reference to which you point me?
>
> thnx,
> Christoph


From: Christoph Boget on
> http://www.w3.org/TR/html4/charset.html
> I hope it can help you.
> PS: json_decode works only in utf8.

I understand charsets. I understand the difference between the
charsets. What I don't understand is how json_encode() is taking the
*exact same input* and behaving differently (breaking in one case,
working in another) depending on the browser being used. And taking
your statement that json_encode() works only in utf-8 as a given, how
can I guard against the different behaviors on the backend, where
json_encode() is getting executed. Should I do some kind of header
sniffing prior to every call to json_encode() and massage the data
accordingly depending on what I find? That seems somewhat excessive.
But based on what you are saying and based on what I'm witnessing, it
seems like there is no other way around that.

thnx,
Christoph
From: "Jo�o C�ndido de Souza Neto" on
Are you setting the charset in your html head?

If not, its using the charset set in your browser, which can be different
from one to another.

In this case, you must set if via meta tag to avoid it.

--
Jo�o C�ndido de Souza Neto

"Christoph Boget" <cboget(a)hotmail.com> escreveu na mensagem
news:AANLkTimbfbgUnifhThZTP+2JNhZgmO8UQvwyDQ4vdu5k(a)mail.gmail.com...
>> http://www.w3.org/TR/html4/charset.html
>> I hope it can help you.
>> PS: json_decode works only in utf8.
>
> I understand charsets. I understand the difference between the
> charsets. What I don't understand is how json_encode() is taking the
> *exact same input* and behaving differently (breaking in one case,
> working in another) depending on the browser being used. And taking
> your statement that json_encode() works only in utf-8 as a given, how
> can I guard against the different behaviors on the backend, where
> json_encode() is getting executed. Should I do some kind of header
> sniffing prior to every call to json_encode() and massage the data
> accordingly depending on what I find? That seems somewhat excessive.
> But based on what you are saying and based on what I'm witnessing, it
> seems like there is no other way around that.
>
> thnx,
> Christoph


From: "Jo�o C�ndido de Souza Neto" on
Sorry about the error:

In this case, you must set IT via meta tag to avoid it.

--
Jo�o C�ndido de Souza Neto

""Jo�o C�ndido de Souza Neto"" <joao(a)consultorweb.cnt.br> escreveu na
mensagem news:16.27.07419.E0E5E7C4(a)pb1.pair.com...
> Are you setting the charset in your html head?
>
> If not, its using the charset set in your browser, which can be different
> from one to another.
>
> In this case, you must set if via meta tag to avoid it.
>
> --
> Jo�o C�ndido de Souza Neto
>
> "Christoph Boget" <cboget(a)hotmail.com> escreveu na mensagem
> news:AANLkTimbfbgUnifhThZTP+2JNhZgmO8UQvwyDQ4vdu5k(a)mail.gmail.com...
>>> http://www.w3.org/TR/html4/charset.html
>>> I hope it can help you.
>>> PS: json_decode works only in utf8.
>>
>> I understand charsets. I understand the difference between the
>> charsets. What I don't understand is how json_encode() is taking the
>> *exact same input* and behaving differently (breaking in one case,
>> working in another) depending on the browser being used. And taking
>> your statement that json_encode() works only in utf-8 as a given, how
>> can I guard against the different behaviors on the backend, where
>> json_encode() is getting executed. Should I do some kind of header
>> sniffing prior to every call to json_encode() and massage the data
>> accordingly depending on what I find? That seems somewhat excessive.
>> But based on what you are saying and based on what I'm witnessing, it
>> seems like there is no other way around that.
>>
>> thnx,
>> Christoph
>
>


From: Christoph Boget on
> Sorry about the error:
> In this case, you must set IT via meta tag to avoid it.

Ok, let's try this using a different approach. Consider the following
pseudo-code:

<?php
$result = mysql_query( 'SELECT name, date FROM table WHERE field = "value"' );
$array = array();
while( $row = mysql_fetch_assoc( $result ))
{
$array[] = $row;
}

$string = json_encode( $array );
?>

Why does the charset of the browser matter one whit to the value of
either $row['name'] or $row['date'] such that it would break
json_encode() in one case and not the other. Is it that PHP is taking
the string which is returned as part of the result set and encoding it
to match the charset passed in from the browser?

thnx,
Christoph

* Disclaimer : the actual code (and data repository) I am using is
slightly different from the above but is similar enough so that it's a
valid representation