<? require ('xajax.inc.php'); $xajax = new xajax(); $xajax->setCharEncoding("windows-1251"); function do_something ($value) { ............Запрос в базу..... $text="Результат запроса"; .................................. $objResponse = new xajaxResponse(); $objResponse->setCharEncoding('windows-1251'); $objResponse->addAssign("div1","innerHTML",$text); return $objResponse; } $xajax->registerFunction("do_something"); $xajax->processRequests(); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <title>xajax example</title> <?php $xajax->printJavascript('../'); </head> <body style="text-align:center;"> <div id="div1" name="div1"> </div> <script type="text/javascript"> xajax_do_something("1"); </script> </body> </html>
function encode($str, $type) { static $conv=''; if (!is_array ( $conv )) { $conv=array (); for($x=128; $x <=143; $x++ ) { $conv['utf'][] = chr(209).chr($x); $conv['win'][] = chr($x+112); } for( $x=144; $x <=191; $x++ ) { $conv['utf'][] = chr(208).chr($x); $conv['win'][] = chr($x+48); } $conv['utf'][] = chr(208).chr(129); $conv['win'][] = chr(168); $conv['utf'][] = chr(209).chr(145); $conv['win'][] = chr(184); } if( $type=='w' ) return str_replace ( $conv['utf'], $conv['win'], $str ); elseif( $type=='u' ) return str_replace ( $conv['win'], $conv['utf'], $str ); else return $str; }
$result = iconv('utf-8', 'cp-1251', $source);