jQuery.ajax handling returned Russian/Chinese HTML data

I have a script that seems to work fine and gets the data back from the server ok for West European Languages. When I try to get Russian or Chinese etc. data, it does not display correctly on the browser.

It must be able to handle many languages like http://translate.google.com/translate_t does
<script src="jquery.js" type="text/javascript" language="javascript" charset="utf-8"></script>
<script src="jquery.form.js" type="text/javascript" language="javascript" charset="utf-8"></script>
<script language="javascript" type="text/javascript">
$.ajax({url: '/cgi-bin/ajaxpost.dll/send', 
        type: 'POST', 
		dataType: 'html',
		contentType: 'text/html; charset=koi8-r',
//		contentType: "text/html; charset=utf-8",
		success: function(data){$(s1).html(data)},
		data: $('#form1').formToArray()

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alfred9847Author Commented:
Thank you cdaugustin for having a stab at this. Unfortunately, I don't use PHP so the articles you mentioned don't lead me very far.

On the other hand, since the responses have been slow getting to me, I have been working on another approach whereby the server does the translation to UTF-8 before sending it and the snippet of code above is left unchanged.

I have been using the Delphi Inspiration components to do so http://www.yunqa.de/delphi/doku.php/products/converters/index 

So far, I have managed to do it for Western European Languages, Russian, Ukrainian, Simplified Chinese and am now busy on Korean.

These components have been sitting on my PC for years and I never had a chance to try them out. Obviously, I would prefer a Javascript solution so I am keeping this question open.

as sugested from my links this is not a javascript problem, but rather a product wide encoding problem. A fix on the JS side would fix only part of your issue. Unfortunatly I cannot help you with Delphi but it would have helped to give more info about your dev environment, im sure there are some Delphi guys out there who have the know how.

good luck
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Alfred9847Author Commented:
Thank you again cdaugustin. I don't really see it as a Delphi problem or a PHP problem. I see it as a Javascript problem. By resorting to server-side programming, I am using a sledgehammer to crack a nut.

http://translate.google.com/translate_t does it quite happily in Javascript and it is that that I would like to be able to replicate. :=)
hmmm, ok, but usually charset problems are compound  problems, check the data that your server script is outputting, then make sure the client is using/having the needed charsets available.
in your case you  would need to see the data the js is trying to send, try to look at it "raw" on the server side.
Alfred9847Author Commented:
<< check the data that your server script is outputting, then make sure the client is using/having the needed charsets available.>>

The server is sending JSON data that contains KOI8-RU  (for Russian), GB 18030 (for Chinese) etc. The webpage is UTF-8 and so Javascript has to handle the conversion depending on the language selected for translation.

<< you  would need to see the data the js is trying to send, try to look at it "raw" on the server side.>>

It is just a regular POST - nothing special there.
if you sure its not transport related, then take a look at


and subsequently at the  


hopefully this will help you out. my above advices were general and came from my experience with charsets, keep in mind that I dont know how your app looks or how well charsets are treated in the other parts of the app. good luck

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Alfred9847Author Commented:
Hi cdaugustin

Since, you are the only person who has tried to be of help, I will give you the points. My subscription is ending soon and I cannot wait much longer.

All the best,

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.