translation tool

Archived from the Xataface Users forum.

Martin Pruss — Tue Jul 21, 2009 1:07 am

Hi Steve hi XF users…

Currently I am trying to translate my DB entries. This works fine with the translation Tool.

But when I add the folowing:

[languages]

de=de

en=en

fr=fr

to my conf ini , all the special characters in the DB like: üäöß

don’t show up correctly.

I already tried to add:

oe = UTF-8

ie = UTF-8

at the beginning of my conf ini with no luck

Do you have any ideas?

Cheers

Martin


Byte — Tue Jul 21, 2009 1:14 am

The information with oe and ie is wrong/depreciated.

Use this (works fro me):

default_oe=”UTF-8”

default_ie=”UTF-8”


Martin Pruss — Tue Jul 21, 2009 2:37 am

Hi Byte…

I tried this as well ..but still no luck…

but thanks for the reply

Martin


Byte — Tue Jul 21, 2009 2:53 am

Since it is working for me:

Do you have all your table fields configured to be UTF-8? This is something that I keep forgetting all the time…


Martin Pruss — Tue Jul 21, 2009 5:24 am

mhh..

I am not sure what consequeces this will have to my data…

will it actually change the data (irreversible)? or does it just change the way the data is rendered? does it change the way data is stored from now on or also the old data?

Currently this data is mostly used in some flash applications on the front end with Xataface as backend.

Only the backend, which is maintained mostly by me and some collegues, shows the wrong characters. So before I mess up the characters on the flash frontend, I better live with the cryptic special characters in the non public backend.

Thanks for your help…

Cheers

Martin


shannah — Tue Jul 21, 2009 11:56 am

It shouldn’t be necessary to change your tables to utf8. That is only necessary if you are using a language like chinese that won’t map nicely from utf8 to latin-1. Mysql makes the conversion for you at runtime.

As you suspect, changing the data format can have repercussions - especially if you have other systems interfacing with the data.

In the resulting HTML page, what does your http-equiv tag say?

e.g.

Code: Select all
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

-Steve


Martin Pruss — Tue Jul 21, 2009 2:21 pm

Hi Steve

It looks like:

Code: Select all
<meta>

Martin Pruss — Tue Jul 21, 2009 2:23 pm

hey … post has been eaten by phpbb

Code: Select all
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

shannah — Tue Jul 21, 2009 2:29 pm

Were these special characters entered using Xataface or using another mechanism?


Martin Pruss — Tue Jul 21, 2009 2:32 pm

post variables from Flash via (external) PHP script

..I forgot to mention that this is still dataface-0.7.1


shannah — Tue Jul 21, 2009 2:46 pm

It could be an encoding issue on that end. If flash/php is (for example) encoding these characters as UTF-8 when they are inserted into the database, but the database is expecting Latin-1, it will still work. And if the application retrieves the text later and displays it - that will work also. However if a different app that is working correctly with the encoding tries to interact with the data, you’ll see that some of these characters look like gibberish.

The key is that the HTML form, the PHP script, and the MySQL database have to be aligned on the type of encoding to use in a given request. The database need not be encoded as UTF-8. MySQL can set the input/output encoding at runtime via the

character_set_client

character_set_results

and names

variables. Here is a snippet from Dataface_Application where Xataface sets this:

Code: Select all
if ( $this->_conf['oe'] == 'UTF-8' ){    $res = mysql_query('set character_set_results = \'utf8\'', $this->_db);    mysql_query("SET NAMES utf8", $this->_db); } if ( $this->_conf['ie'] == 'UTF-8' ){    $res = mysql_query('set character_set_client = \'utf8\'', $this->_db);           }

This must be done to tell mysql that it is working in UTF-8 for this request.

Do you know whether your flash script and PHP script are working with the data as utf-8 or latin-1?

My prediction to support this hypothesis is: If you try to enter a record via Xataface using special characters, they will come out looking right in Xataface. But in your Flash app they will probably look gibbled.

-Steve


Martin Pruss — Wed Jul 22, 2009 1:01 am

Hi Steve..

My prediction to support this hypothesis is: If you try to enter a record via Xataface using special characters, they will come out looking right in Xataface

Not quite… öäüß becomes öüäß after saving in xataface (0.7.1).

When i remove:

Code: Select all
[languages] de=de en=en fr=fr

from conf ini the special characters are displayed properly.

How do I find out wether php is working with the data as utf8 or latin-1?
In the script there is no definition about this..
it is just receiving POST variables and inserts them in my DB like this:

Code: Select all
'" . mysql_real_escape_string($_POST[id]) . "',

Thanks for continuously taking care of my coding problems

Martin


Jean — Wed Jul 22, 2009 6:57 am

Hi Martin,

Some questions :

Are your files saved in UTF-8 without BOM ? It is possible with free editors like PSPad…
Is your Apache server (httpd.conf) or a .htaccess configured with

Code: Select all
AddDefaultCharset UTF-8

Cheers

Jean


Martin Pruss — Wed Jul 22, 2009 7:55 am

Hi Jean…

When i do this:

Code: Select all
AddDefaultCharset UTF-8

All special characters are wrong
after i removed:

Code: Select all
[languages] de=de en=en fr=fr

When i insert it again and define a htaccess with “AddDefaultCharset UTF-8” only for the backend

everything works….yippee

but only for the database entries..

i probably have to save all field ini files without “bom” because they now show a ? instead of special characters

Thanks for your help

Martin


Jean — Wed Jul 22, 2009 8:22 am

Don’t forget to save your language files in UTF-8 without BOM too…

I noticed something:

sometime you have to save in ANSI then in UTF-8 to have them correct.


shannah — Tue Jul 21, 2009 2:46 pm

It could be an encoding issue on that end. If flash/php is (for example) encoding these characters as UTF-8 when they are inserted into the database, but the database is expecting Latin-1, it will still work. And if the application retrieves the text later and displays it - that will work also. However if a different app that is working correctly with the encoding tries to interact with the data, you’ll see that some of these characters look like gibberish.

The key is that the HTML form, the PHP script, and the MySQL database have to be aligned on the type of encoding to use in a given request. The database need not be encoded as UTF-8. MySQL can set the input/output encoding at runtime via the

character_set_client

character_set_results

and names

variables. Here is a snippet from Dataface_Application where Xataface sets this:

Code: Select all
if ( $this->_conf['oe'] == 'UTF-8' ){    $res = mysql_query('set character_set_results = \'utf8\'', $this->_db);    mysql_query("SET NAMES utf8", $this->_db); } if ( $this->_conf['ie'] == 'UTF-8' ){    $res = mysql_query('set character_set_client = \'utf8\'', $this->_db);           }

This must be done to tell mysql that it is working in UTF-8 for this request.

Do you know whether your flash script and PHP script are working with the data as utf-8 or latin-1?

My prediction to support this hypothesis is: If you try to enter a record via Xataface using special characters, they will come out looking right in Xataface. But in your Flash app they will probably look gibbled.

-Steve


Martin Pruss — Wed Jul 22, 2009 1:01 am

Hi Steve..

My prediction to support this hypothesis is: If you try to enter a record via Xataface using special characters, they will come out looking right in Xataface

Not quite… öäüß becomes öüäß after saving in xataface (0.7.1).

When i remove:

Code: Select all
[languages] de=de en=en fr=fr

from conf ini the special characters are displayed properly.

How do I find out wether php is working with the data as utf8 or latin-1?
In the script there is no definition about this..
it is just receiving POST variables and inserts them in my DB like this:

Code: Select all
'" . mysql_real_escape_string($_POST[id]) . "',

Thanks for continuously taking care of my coding problems

Martin


Jean — Wed Jul 22, 2009 6:57 am

Hi Martin,

Some questions :

Are your files saved in UTF-8 without BOM ? It is possible with free editors like PSPad…
Is your Apache server (httpd.conf) or a .htaccess configured with

Code: Select all
AddDefaultCharset UTF-8

Cheers

Jean


Martin Pruss — Wed Jul 22, 2009 7:55 am

Hi Jean…

When i do this:

Code: Select all
AddDefaultCharset UTF-8

All special characters are wrong
after i removed:

Code: Select all
[languages] de=de en=en fr=fr

When i insert it again and define a htaccess with “AddDefaultCharset UTF-8” only for the backend

everything works….yippee

but only for the database entries..

i probably have to save all field ini files without “bom” because they now show a ? instead of special characters

Thanks for your help

Martin


Jean — Wed Jul 22, 2009 8:22 am

Don’t forget to save your language files in UTF-8 without BOM too…

I noticed something:

sometime you have to save in ANSI then in UTF-8 to have them correct.


shannah — Wed Jul 22, 2009 9:21 am

Martin,

Can you post your conf.ini file (remove your db connect into of course)?

-Steve


Martin Pruss — Thu Jul 23, 2009 12:32 am

hi Steve

Code: Select all
`;;default_oe=”UTF-8”
;;default_ie=”UTF-8”
[languages]
de=de
en=en
fr=fr

[history]
enabled=1

;; The Web Site Title
title = “xxx”

debug=0
default_action=list

[_prefs]
show_jump_menu = 0 ; hides the jump menu

[_database]
host = “localhost”
user = “xxx”
password = “xxx”
name = “xxx”

[_tables]
neu_fragen = “x-Datenbank”
users = “kunden”
jos_events = “events”
schuh = “schuhe”
transl_questions = “Fragen”
transl_answers = “Antworten”

[_auth]
users_table = users
username_column = UserName
password_column = Password`

cheers

Martin


shannah — Thu Jul 23, 2009 9:07 am

A few notes.

  1. I notice that you have commented out your default_oe and default_ie directives. These should be uncommented. Then try to enter special chars in xataface - and see if they come out.

  2. Your title, debug, and default_action directives won’t be effective because they are part of the history section. These should appear before your first section definition. (this isn’t related, but worth noting).


Martin Pruss — Thu Jul 23, 2009 11:17 am

Thanks to all who helped..

After saving my fields.ini UTF8 encoded and removing the comments in my conf ini everything works fine!