X-JSON encoding problem

G

Gene

Hi,
I have problem with X-JSON. I am sending, in header, Polish chars,
that are correct encoded in database, but when they came through
header something wrong happen with encoding and I can only see
strange
signs at page. I am using UTF-8.

Please help, because all my ajax requests are based on sending data
in
header.

Sincerely,
Gene
 
G

Gufo Rosso

Gene ha scritto:
Hi,
I have problem with X-JSON. I am sending, in header, Polish chars,
that are correct encoded in database, but when they came through
header something wrong happen with encoding and I can only see
strange
signs at page. I am using UTF-8.

Please help, because all my ajax requests are based on sending data
in
header.
{data: base64_encode(stringdata)}
 
B

Bart Van der Donck

Gufo said:
Gene ha scritto:

HTTP headers can only contain ASCII characters.

There are many choices to store Polish characters: ISO 8859-2,
Windows-1250, ISO-IR 101, UTF-7, UTF-8, UTF-16, ... None of those is
more "correct" than the other.

What are these strange signs ? When you want UTF-8, I suspect that,
for example, a Polish character like:

\u017a (LATIN SMALL LETTER Z WITH ACUTE)

from database could be displayed on your screen like:

\u00c5\u00ba (LATIN CAPITAL LETTER A WITH RING ABOVE, followed
by MASCULINE ORDINAL INDICATOR)

This means that the two-byte sequence is not recognized as UTF-8.

There are three actors involved:
- Which encoding is used by the database
- How it read by the app and transferred (Content-Type header)
- How the webpage displays the data
{data: base64_encode(stringdata)}

Base64-encodings should only be used to transfer binary data over 7-
bit paths. It makes no sense to use it for UTF-8. You are
theoretically correct that the data will be ASCII-safe (as required
for HTTP headers), but far too big to be stored there. The body-part
of the message is intended for this task.

Hope to have helped more than confused,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top