Topic: Russian Encoding | Windows-1251

Hellow,
This is my solution:

When text comming from script to xAJAX-function you must decode it from utf-8 to windows-1251. For example:

function insert_into_db($incoming_text) {
    $text_to_insert_into_db = iconv("utf-8", "windows-1251", $incoming_text); 
}

If you want to insert text from xAJAX-function into HTML-document, you muset decode text from windows-1251 to utf-8. For example:

function insert_into_html_document() {
    $objResponse = new xajaxResponse();
    $text_to_insert_into_div= iconv("windows-1251", "utf-8", $incoming_text_from_db);
    $objResponse->addAssign("my_div", "innerHTML", $text_to_insert_into_div);    
    return $objResponse;
}
Sorry for my bad English

Re: Russian Encoding | Windows-1251

You know, i use windows-1251 without all that stuff and everything is ok for me.

Here is my sample:

define(RU,"1");//for windows-1251
include_once ("../xajax/xajax.inc.php");

$xajax = new xajax();
if (RU==1) $xajax->setCharEncoding('windows-1251');
if (RU==1) $xajax->decodeUTF8InputOn();

$xajax->statusMessagesOn();
$xajax->errorHandlerOn();

$xajax->registerFunction("process_form");
$xajax->registerFunction("process_browse_url");
$xajax->processRequests();

also for objResponse:

$objResponse = new xajaxResponse();
if (RU==1) $objResponse->setCharEncoding('windows-1251');

If i use UTF-8 i juts comment the first line (define).
Is there any problems you have with it?

Re: Russian Encoding | Windows-1251

Thanks for this solution!

Little syntax mistake:

define("RU", 1);//for windows-1251
Sorry for my bad English

Re: Russian Encoding | Windows-1251

Well, I use also the windows-1251 encoding and it works perfecly well, but a exception ....
Actually, if I can't deal with greek caracters with this enconding .... which is really a pity !
For example, I want to add a record in my database, and I just make a copy/paste of this text :
"The vibrations were / ??????? ???? : VXE131 – 35 ?m ( 10?m before shut down / ????? ???????)"
I obtain M "The vibrations were / ??????? ???? : VXE131 – 35 "

Is there a way to use without pbs all chars ?? are a way to test charaters that are not supported to inform the user ??

Thank you for your answer !

And thank you ( J. Max Wilson, JaredWhite, BBC,... ) for this understable usage of xajax ! Thanks to you I'm able to do what I want, even if it's far from the perfection, it works ! And that rocks !!!
Vincent

5 (edited by Akim 2006-06-23 10:57:54 AM)

Re: Russian Encoding | Windows-1251

I tried to use this way:

define("RU","1");//for windows-1251
include_once ("../xajax/xajax.inc.php");

$xajax = new xajax();
if (RU==1) $xajax->setCharEncoding('windows-1251');
if (RU==1) $xajax->decodeUTF8InputOn();

$xajax->statusMessagesOn();
$xajax->errorHandlerOn();

$xajax->registerFunction("process_form");
$xajax->registerFunction("process_browse_url");
$xajax->processRequests();


...... and so on

but this don`t work.
Does it need the iconv extension?

Re: Russian Encoding | Windows-1251

Akim wrote:

I tried to use this way:

define("RU","1");//for windows-1251
include_once ("../xajax/xajax.inc.php");

$xajax = new xajax();
if (RU==1) $xajax->setCharEncoding('windows-1251');
if (RU==1) $xajax->decodeUTF8InputOn();

but this don`t work.
Does it need the iconv extension?

This code quite enough and work well. Look for another reason (maybe browser or server encodings?)

Re: Russian Encoding | Windows-1251

Akim, doublecheck you have the mb_string extension installed

8 (edited by mstar 2006-06-26 6:56:32 AM)

Re: Russian Encoding | Windows-1251

Akim wrote:

but this don`t work.

Could you give the error? ($xajax->debugOn(); )

Re: Russian Encoding | Windows-1251

In version 0.5 B2 the given decision does not work for addition of the information in a database.
For example, data sent from form. If to deduce them through alert, they in the normal coding and if right after it to add them in a database the coding gets off. The following trial inquiry adds in a database data in the normal coding.

$xajax = new xajax();
$xajax->setCharEncoding('windows-1251');

function my($data) {
    $objResponse = new xajaxResponse();
    $objResponse->alert($data['key']);
    ...
    return $objResponse;
}

Sorry for my bad English

Re: Russian Encoding | Windows-1251

This work? Really work! Any others not work. This I fined at the internet.

define  ('XAJAX_DEFAULT_CHAR_ENCODING',  'cp1251');
require_once("xajax_core/xajax.inc.php");
$xajax = new xajax();

Sorry, I don't speak English...