Special characters with JSON

1,336 views
Skip to first unread message

jme_loose

unread,
Feb 3, 2011, 6:16:40 AM2/3/11
to jsTree
Apologies if this has been answered else where but I've done a search
and can't find a satisfactory answer.
The problem is to do with special characters in node names, like the
copyright symbol. I am using JSON to send and receive data from the
server. PHP version is 5.1.6 and therefore I have to use a manual
function for the JSON encode and is set to use UTF-8. Your supplied
mysql classes also set the mysql link to use UTF-8. I have outputted
the received JSON encoded text for a reg mark to the server
error_log() and it appears as \xc2\xae. I understand the unicode for
reg is &#x00AE. The problem is that when the data is retrieved for
display it just appears as a ?.

Any help would be much appreciated.

jme_loose

unread,
Feb 3, 2011, 6:21:33 AM2/3/11
to jsTree
Sorry, I wanted this bit to appear as:

"I understand the unicode for reg is #x00AE;"

On Feb 3, 11:16 am, jme_loose <ellip...@yahoo.co.uk> wrote:
> Apologies if this has been answered else where but I've done a search
> and can't find a satisfactory answer.
> The problem is to do with special characters in node names, like the
> copyright symbol. I am using JSON to send and receive data from the
> server. PHP version is 5.1.6 and therefore I have to use a manual
> function for the JSON encode and is set to use UTF-8. Your supplied
> mysql classes also set the mysql link to use UTF-8. I have outputted
> the received JSON encoded text for a reg mark to the server
> error_log() and it appears as \xc2\xae. I understand the unicode for
> reg is ®. The problem is that when the data is retrieved for

Ivan Bozhanov

unread,
Feb 7, 2011, 8:08:34 AM2/7/11
to jst...@googlegroups.com
I will take a deeper look and let you know. Sorry I do not have an answer right away. Btw have you tried converting to HTML entities or that is not an option?

Kindest regards,
Ivan

mvwd

unread,
Feb 18, 2011, 12:38:38 AM2/18/11
to jsTree
I'm dealing with filenames:
PHP lists files, converts to JSON which will end up in a jsTree. In
german there are a lot of "umlauts" like ä ö ü... Because of them i
need to convert between UTF-8 and ISO.

- Data received from jsTree (creating, renaming, moving files/folders)
needs to convert from UTF-8 using decode_utf8().
- Data sending from PHP to jsTree needs to be converted using
encode_utf8()

And: make sure PHP sends a header identify the data as UTF-8 using:
header('Content-Type: text/html; charset=utf8');

A bit tricky sometimes, but works for me.

Markus.
Reply all
Reply to author
Forward
0 new messages