开发者

Problem storing german chars in the MySQL database.....?

开发者 https://www.devze.com 2023-03-16 07:52 出处:网络
I have a table named \"cust_details\" which has a column \"categories\", where I have to store some categories like : blockadenlösung, affirmation, beziehungsprobleme lösen

I have a table named "cust_details" which has a column "categories", where I have to store some categories like : blockadenlösung, affirmation, beziehungsprobleme lösen

But when I am trying to save this data into the database it is stored like :

blockadenlüsung, affirmation, beziehungsprobleme lösen

That is when umlauts are coming in the s开发者_Go百科tring it is not saved in its original form. I tried some charset for storing this characters. But I am still facing the problem.....

What may be the possible reasons...?

Thanks In Advance.....


The data you stored is encoded in UTF-8 (ü for an "ö" is typical for UTF-8), but is not displayed as UTF-8 but rather as ISO-8859-1 or the like.

Make sure that you use the same encoding everywhere:

  • Deliver your websites with Content-Encoding "utf-8"
  • Use mysql_query("SET NAMES 'utf8'"); to set the encoding to utf-8
  • Make sure that the encoding of the database is UTF-8 (use HeidiSQL etc. to check)


Use this when you are inserting the characters:

N'characters here'

The N before the string declaration should enable you to enter it into the DB.


What is the type of the field?

You could specify database/table/field level character-sets. The default latin-1 works in most scenarios.

Otherwise, you would have to use plain text and store unicode strings like &#<4-digit-unicode-value>; into it. Then when you print it out, just dump the unicode into HTML and it will show up as such.

Here is a sample string in Pashto &#1578;&#1585;&#1575;&#1601;&#1610;&#1705;&#1610; &#1662;&#1610;&#1690;&#1608; &#1705;&#1744; &#1583;&#1585;&#1744; &#1578;&#1606;&#1607; &#1605;&#1683;&#1607; &#1575;&#1608; &#1669;&#1608;&#1575;&#1585;&#1604;&#1587; &#1606;&#1608;&#1585; &#1660;&#1662;&#1610;&#1575;&#1606; &#1588;&#1608;&#1604;. which we store directy into the table. The charset used is latin_charset_ci

Good Luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消