I want mysql table to support two languages

淺唱寂寞╮ 提交于 2019-12-23 23:17:13

问题


I have a jsp form, there is the next line in the code:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

I send the parameters of the form into a table in mysql.

the parameters can be in english or hebrew.

I looked if mysql supports the hebrew language:

show character set;

and got:

| hebrew   | ISO 8859-8 Hebrew           | hebrew_general_ci   |      1 |

but, when I inserts parameters in hebrew, the fit in mysql shows something like:

╫⌐╫?╫?╫?╫?╫?

I am trying also to print the parameters in my jsp file and got strange letters..

how can I update my code in order to support english and hebrew?


回答1:


As an example to create a new table with utf-8 ecoding, this should work for you;

CREATE TABLE IF NOT EXISTS `test` (
  `id` int(10) NOT NULL,
  `name` varchar(10)
  collate utf8_unicode_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



回答2:


Do

SET CHARACTER SET 'utf8';

right after you make a connection. I had the exact same problem with a different language and this fixed it.



来源:https://stackoverflow.com/questions/13686510/i-want-mysql-table-to-support-two-languages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!