Wasim A.
Wasim A.

Reputation: 9890

PHP UTF-8 Encoding in HTML Input Box

Here what is in database

Seilpendel für Tragsysteme

now i am loading it into textbox via AJAX but what loads into textbox is

Seilpendel f�r Tragsysteme

but i want correct string Seilpendel für Tragsysteme into inputbox

i have tried

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

but not its working

Upvotes: 2

Views: 4374

Answers (3)

Starx
Starx

Reputation: 78971

The correct way solving this problem is to configure database to use UTF8 as their character encoding in and out.

RUN The following query after connecting to the database, one time and everything should start working.

SET NAMES 'utf8';

Upvotes: 2

mcdado
mcdado

Reputation: 728

Make sure the db is encoded in UTF8, or use utf8_encode() or utf8_decode() when loading data from db or when writing back.

Upvotes: 1

Yaron U.
Yaron U.

Reputation: 7881

make sure that you also save the file with UTF8 encoding

you can open it in notepad (or even better - notepad++) and on the "Save As..." popup - select UTF8 instead of the default ANSI

if you're using notepad++ select utf-8 without BOM

if the file's encoding is ok make sure that the connection to the DB is in utf-8 you can do it by querying: SET NAMES 'utf8'

Upvotes: 1

Related Questions