HTML中的utf-8编码和MySQL的utf8_unicode_ci字符集和校对 - 我现在可以在其中存储和显示任何类型的文本吗?

时间:2023-01-06 11:25:02

I want to dvp a small web app which would ideally be used worldwide. For the sake of the discussion, let's say it's a recipe sharing site - it's a good enough metaphor.

我想要一个理想的全球范围内使用的小型网络应用程序。为了讨论起见,让我们说这是一个配方共享网站 - 这是一个足够好的比喻。

My app will allow users to enter or upload text in their native languages. My html header says that the site uses utf-8 encoding. I am now creating my MySQL db, and I suppose that I should select utf8_unicode_ci for the char set & collation.

我的应用程序将允许用户以其母语输入或上传文本。我的html标题说该网站使用utf-8编码。我现在正在创建我的MySQL数据库,我想我应该为char set和collat​​ion选择utf8_unicode_ci。

Is that correct?

那是对的吗?

Is that all I need to do to be able to receive, store, and display safe user-generated-content in their chosen language? If not, what am I missing?

这就是我需要做的就是能够以他们选择的语言接收,存储和显示安全的用户生成内容吗?如果没有,我错过了什么?

(I am aware of the safety concerns associated with displaying UGC, this is not what the question is about - here I am solely looking for advice to deal with safe content.)

(我知道与显示UGC相关的安全问题,这不是问题所在 - 在这里我只是寻求处理安全内容的建议。)

2 个解决方案

#1


1  

It is all for you HTML and DB part, but you must ensure that the programming language is UTF-8 aware so it doesn't garble your stuff. If you use PHP just make sure that the functions you use are UTF-8 aware. If it isn't the manual usually mentions it.

这完全适用于HTML和数据库部分,但您必须确保编程语言具有UTF-8感知能力,因此它不会使您的内容变得混乱。如果您使用PHP,请确保您使用的功能是UTF-8。如果不是手册,通常会提到它。

#2


1  

As far as the html and the db i think this is all you need. The only other part you may need to define that your inputs are UTF-8 encoded, is the part where you send/receive your data (assuming with a form and a post request for example). You can check post #:1281123 in this forum, it helped a lot when i had some problems with encoding in a similar situation.

至于html和db我认为这就是你所需要的。您可能需要定义输入为UTF-8编码的唯一其他部分是您发送/接收数据的部分(例如,假设有表单和发布请求)。你可以在这个论坛上查看帖子#:1281123,当我遇到类似情况下的编码问题时,它帮了很多忙。

#1


1  

It is all for you HTML and DB part, but you must ensure that the programming language is UTF-8 aware so it doesn't garble your stuff. If you use PHP just make sure that the functions you use are UTF-8 aware. If it isn't the manual usually mentions it.

这完全适用于HTML和数据库部分,但您必须确保编程语言具有UTF-8感知能力,因此它不会使您的内容变得混乱。如果您使用PHP,请确保您使用的功能是UTF-8。如果不是手册,通常会提到它。

#2


1  

As far as the html and the db i think this is all you need. The only other part you may need to define that your inputs are UTF-8 encoded, is the part where you send/receive your data (assuming with a form and a post request for example). You can check post #:1281123 in this forum, it helped a lot when i had some problems with encoding in a similar situation.

至于html和db我认为这就是你所需要的。您可能需要定义输入为UTF-8编码的唯一其他部分是您发送/接收数据的部分(例如,假设有表单和发布请求)。你可以在这个论坛上查看帖子#:1281123,当我遇到类似情况下的编码问题时,它帮了很多忙。