HighDots Forums  

X-JSON encoding problem

Javascript JavaScript language (comp.lang.javascript)


Discuss X-JSON encoding problem in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gene
 
Posts: n/a

Default X-JSON encoding problem - 06-11-2008 , 01:34 AM






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

Reply With Quote
  #2  
Old   
Gufo Rosso
 
Posts: n/a

Default Re: X-JSON encoding problem - 06-11-2008 , 01:57 AM






Gene ha scritto:
Quote:
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)}



Quote:
Sincerely,
Gene

Reply With Quote
  #3  
Old   
Bart Van der Donck
 
Posts: n/a

Default Re: X-JSON encoding problem - 06-11-2008 , 07:25 AM



Gufo Rosso wrote:

Quote:
Gene ha scritto:

I have problem with X-JSON. I am sending, in header, Polish chars,
HTTP headers can only contain ASCII characters.

Quote:
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.

Quote:
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

Quote:
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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.