如何以印地文语言将数据存储在unicode中 [英] How to store the data in unicode in hindi language

查看:101
本文介绍了如何以印地文语言将数据存储在unicode中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将PHPMySQL用于应用程序.

I am using PHP and MySQL for an application.

问题是:

  1. 如何以MySQL नवीन खेतिहर उपकरण।可读格式或निलेस र पà¥à¤¬格式存储数据

  1. How to store data in MySQL नवीन खेतिहर उपकरण। readable format or निलेस र पà¥à¤¬ format

当用户在文本框中输入数据并单击提交"时,那时我们将获得不同格式的数据.我们应该做的是,以可读格式将其转换并存储在MySQL中.

When user enters data in a textbox and clicks on submit, at that time we get data in different format. What we need to do should we convert and store in MySQL in readable format.

推荐答案

选择utf8字符集和utf8_general_ci归类.

Choose utf8 character set and utf8_general_ci collation.

很明显,该字段(要将印度语文本存储到的字段)应为utf8_general_ci.

Obviously, Collation of the field (to which you want to store Hindi text) should be utf8_general_ci.

要更改表格字段,请运行

To alter your table field, run

ALTER TABLE `<table_name>` CHANGE `<field_name>` `<field_name>` VARCHAR(100) 
CHARSET utf8 COLLATE utf8_general_ci DEFAULT '' NOT NULL;

连接到数据库后,首先运行以下语句

Once you've connected to database, run the following statement at first

mysql_set_charset('utf8');

例如:

//setting character set
mysql_set_charset('utf8');

//insert Hindi text
mysql_query("INSERT INTO ....");

要检索数据

//setting character set
mysql_set_charset('utf8');

//select Hindi text
mysql_query("SELECT * FROM ....");

在浏览器上打印任何unicode文本(例如印地语文本)之前,您必须通过添加元标记来设置该页面的内容类型

Before you printing any unicode text (say Hindi text) on browser, you should have to set content type of that page by adding a meta tag

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

例如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example Unicode</title>
</head>

<body>
<?php echo $hindiText; ?>
</body>
</html>

更新:

mysql_query("SET CHARACTER SET utf8") has changed to mysql_set_charset('utf8'); 这是更改字符集的首选方法.不建议使用mysql_query()进行设置(例如SET NAMES utf8).参见 http://php.net/manual/en/function.mysql-set-charset.php *

mysql_query("SET CHARACTER SET utf8") has changed tomysql_set_charset('utf8'); This is the preferred way to change the charset. Using mysql_query() to set it (such as SET NAMES utf8) is not recommended. See http://php.net/manual/en/function.mysql-set-charset.php*

这篇关于如何以印地文语言将数据存储在unicode中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆