Thariama
Thariama

Reputation: 50832

Way to create a multi language inputfield

I have a form with an inputfield. When i write text into it containing umlauts, save the values to db and reload the page, i see the written text with the umlauts in the form as i typed them in. Example: I type Bär, after saving ang reloading the page i see Bär.

Now, the problem is when i insert russian or chinese letters they show up as expected. But when i save them to db and reload the page i get the wrong representation of the characters.

Example: I write Москва. After saving the form and page reload i see Москва. This looks like html entities that do not get displayed correctly, but i think this are unicode hex character codes.

How can i store and retrieve such foreign letters that they are displayed correctly in my html form?

Upvotes: 0

Views: 183

Answers (2)

Thariama
Thariama

Reputation: 50832

Found the solution myself.

Actually the values of the inputfield get utf-8 encoded first and then cp1252 encoded before they get written to the database.

When i retrieve the inputfield data from the database i need to call this little replacement (perl code)

$inputfield_text=~ s/&(#[xX]?[0-9a-fA-F]+;)/&$1/g;

before i output the string.

Upvotes: 0

dwilda
dwilda

Reputation: 83

First of all try by adding
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
If that does not work, check default collaction in database and table. I'm always using utf8_general_ci when I have to work with translations and that work for me

Upvotes: 1

Related Questions