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