Menu

How to change encoding

Help
2009-01-10
2013-04-25
  • Paul Nesmiyanov

    Paul Nesmiyanov - 2009-01-10

    Hello!
    I'm trying to "teach" bot to speak Russian, so I've made some changes into different *.php, *.aiml, startup.xml, so that now encoding of that pages is windows-1251 (cyrillic). But still when I'm trying to speak with bot, answers (templates I've changed to russian) are unreadable "abracadabra". In browser (Mozilla) encoding set properly (windows-1251). How can I make bot speak with me in Russian? :)

    Thank you for your attention and great work!

     
    • Anne Kootstra

      Anne Kootstra - 2009-01-11

      It is indeed possible to use Program E in a non-Latin based languages but will require a few changes in Program E. These changes need to be done for the 0.9 release, but for the next release UTF-8 will come standard. This release should be available in a month or two.

      I will outline the changes I remember I made for UTF-8 and I think if you follow them you will be able to use Russian as well. However, if you require to use the Cyrillic windows-1251 encoding then you at least know where to make your modifications.

      The manual changes that need to be made were inspired by the following post: http://forum.tufat.com/showthread.php?t=48553. However, I also looked beyond this because the encoding can and has to be adjusted in more places:

      1. Change the database table and columns collation to utf8_unicode_ci

      2. Change the encoding in the XML files to UTF-8 in the XML header.

      3. Also set the file encoding itself to UTF-8. In an editor like eclipse you can do this under File->Options.

      3. In dbprefs.php right after the connection is made run the following SQL query to set the database connection to UTF-8 to ensure that the communication between Program E (PHP) and the Database Server backend is also in UTF-8.

      mysql_query("SET NAMES utf8");
      mysql_query("SET CHARACTER SET utf8");

      4. in Talk.php right after the <?php declaration set the output to utf-8:

      header('Content-type: text/html; charset=UTF-8') ;

      5. In Talk.php add to the form tag with the following attributes to ensure that the form input will be send as UTF-8:

      method="post" accept-charset="UTF-8"

      6. Change the subsitution routine as per suggested above link.

      Please share your experiences and if you needed to make any additional changes as well.

      Kind regards,

      Anne Kootstra

       
      • Paul Nesmiyanov

        Paul Nesmiyanov - 2009-01-14

        Sorry, I'm not sure about p.3
        Where shoul i make this query?
        When I try this, the program answers:
        #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql_query("SET NAMES utf8")' at line 1

        I use  phpMyAdmin 2.6.1
        Thanks!

         
    • Paul Nesmiyanov

      Paul Nesmiyanov - 2009-01-13

      Thanks a lot! I'll try your changes.

       
    • Anne Kootstra

      Anne Kootstra - 2009-01-14

      Can you please tell me if you put the following PHP code in dbprefs.php or in phpMyAdmin?

      mysql_query("SET NAMES utf8")

      It should be included in dbprefs.php.

      Kind regards,

      Anne.

       
      • Paul Nesmiyanov

        Paul Nesmiyanov - 2009-01-21

        Thanks a lot!!!

         

Log in to post a comment.