CodeIgniter Forums
encoding problam with ajax - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: encoding problam with ajax (/thread-12107.html)

encoding problam with ajax - El Forum - 10-06-2008

hello everyone

i a working on a comment form and i am sending the form with ajax (jQuery) and i am using the plugin ajaxForm.

so i have this ajax code:
   $(document).ready(function() {

      <!-- sending the comment form -->
      $('#commentSend').ajaxForm(function(data) {
         alert(data); //here i am just validating that it sends


i am using a simple HTML form, and in my controller i am just checking the fields and save them.
everything works fine expets when i am not writing the comment in english.
when i write it in other characters it encodes it to different thing, and in the DB it looks like that:

i added this:
header('Content-Type: text/html; charset=windows-1255');
to my controller but it still doesn't help.

can anyone help me?

encoding problam with ajax - El Forum - 10-06-2008

In what format are your files encoded ?

encoding problam with ajax - El Forum - 10-07-2008

ok i solved the thing.
after searching in google i found this functions that converts UTF-8 to the charset that i need:
function iconv_cp1255_utf8 ($cp1255) {
     return preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$cp1255);