By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,576 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,576 IT Pros & Developers. It's quick & easy.

X-JSON encoding problem

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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)}
Sincerely,
Gene
Jun 27 '08 #2

P: n/a
Gufo Rosso wrote:
Gene ha scritto:
>I have problem with X-JSON. I am sending, in header, Polish chars,
HTTP headers can only contain ASCII characters.
>that are correct encoded in database,
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.
>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.
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
>Please help, because all my ajax requests are based on sending data
in header.

{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,

--
Bart
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.