PDA

View Full Version : How to make data.Connection return data in non-English languages?



maya
21 Sep 2007, 1:04 AM
Hi,

I have a problem receiving non-English data from data.Connection object.

When I use a simple (non-Ext) AJAX call that calls a php file, I add to my php file:
header('Content-Type: text/html; charset=windows-1255'); (or a different charset - according to the expected returned language) - and the returned data is OK.

But, when I try to use Ext.data.Connection that calls the same php file, I receive an empty string. Only if the returned data is in English - I receive a proper string.

Do I need to define the charset differently when using Ext.data.Connection?
If yes - how can I define the language there?

Thanks,
Maya

Animal
21 Sep 2007, 1:19 AM
THis is a server-side issue. It's all very well setting the header promising that you are sending characters encoded using a certain scheme, but you then have to ensure that you use that scheme to encode your characters into a stream of bytes.

Are you doing that?

maya
23 Sep 2007, 12:32 AM
Thanks for your answer, Animal.

How can I "ensure that I use that scheme to encode my characters into a stream of bytes"?
I encode my text using json_encode($text).

Should I use another encoding function before the json_encode?

Thanks,
Maya

Animal
23 Sep 2007, 11:38 AM
I don't know. It's down to your server language.

I could tell you how to specify encoding for Java, but you're PHP.

Try a PHP forum.

steffenk
23 Sep 2007, 2:53 PM
i made a collection of issues how to use utf-8 in php, may that helps you
http://www.traum-projekt.com/forum/19-traum-dynamik/86425-wichtige-php-tipps.html#2

it's in german, but code is readable.

maya
24 Sep 2007, 4:08 AM
Thanks for your answers, but I don't understand why you consider it as a Server issue: a standard AJAX call presents my text correctly when I write in my php file the correct header line (e.g., header('Content-Type: text/html; charset=windows-1255'); ). When replacing the simple AJAX call with an Ext component (e.g., Connection, Tree, Grid that loads data from the server) - I receive an empty string.

Why Ext components are different? What extra definitions they need?

Do I need to add header definitions to those object constructors?
For example, data.Connection has a config option named: "defaultHeaders" - maybe this is the direction for solving my problem?

What do you think?

Thanks,
Maya

steffenk
24 Sep 2007, 5:20 AM
i don't have these problems. I neither declare a header - my server runs with utf-8 as default, no problems using ext- or other ajaxrequests.

maya
24 Sep 2007, 5:32 AM
Can you see non-English text in Ext Tree or text received from data.Connection?

steffenk
24 Sep 2007, 7:41 AM
i have German texts using

maya
24 Sep 2007, 10:26 AM
Are you using data.Connection to get this text?

Any ideas why I do not receive text? (I need to use windows-1255 and not UTF-8, which I think is the default charset).

Thanks again,
Maya

steffenk
24 Sep 2007, 1:19 PM
sure i use data.connecton - it's standard method for retrieving data from external script.
Please show you're code, maybe there is something wrong.

maya
23 Nov 2007, 2:56 PM
Hi Steffen,

Thanks for your help. I discovered my problem and it was related to JSON in PHP. After solving this problem in the server side, it works fine.

Thanks again,
Maya