charset conflict db vs frontend [英] charset conflict db vs frontend

查看:84
本文介绍了charset conflict db vs frontend的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我目前处于Charset地狱。



基本上我正在开发一个数据库驱动的网站。不是网站包含直接来自数据库的很多页面,很少是静态html。



现在db charset是 -

Hello,

I am currently in a Charset hell.

Basically i am working on a database driven site. Not the site contains lot of pages coming directly from the database and few are static html.

Now db charset is -

Default character set = utf8
Default collation = utf8_general_ci





在前端 -



如果我将字符集设置为 utf8_general_ci ,然后来自db的内容工作正常,但静态页面在连字符等上显示奇怪的字符。



现在,如果我将字符集设置为 utf- 8 相反,它适用于静态html页面,但显示奇怪的问号符号。



那不是 -



在CMS中,



如果我设置为 utf8_general_ci ,当编辑器尝试添加内容时会删除内容 - (ndash)但是将其转换为 utf8 会排除此问题但是有仍然很少html字符像大于等于等不起作用。



任何想法我们在这里做错了什么?



谢谢



In front end -

if I set charset to utf8_general_ci, then content coming from db works fine but the static pages show weird characters on hyphen etc.

Now if I set charset to utf-8 instead, then it works on static html pages but displays weird question mark symbols.

That's not it -

In CMS,

if i set to utf8_general_ci, content gets deleted when editor tries to add -- (ndash) but chaning it to utf8 sorts this problem out but there are still few html characters like greater than equal to etc that doesn't work.

Any ideas what are we doing wrong here?

Thanks

推荐答案

很难回答,因为你没有说明前端是什么。

但是如果你看一下使用ASP时你可以在Web.Config文件中做的设置.Net你可能会知道你可以改变什么。

Tough to answer as you haven't stated what the frontend is.
But if you look at the settings you can do in the Web.Config file when using ASP.Net you might get an idea on what you can change.
<configuration>
  <system.web>
    <globalization>
      fileEncoding="utf-8"
      requestEncoding="utf-8"
      responseEncoding="utf-8"
      culture="en-US"
      uiCulture="de-DE"
    </globalization>
  </system.web>
</configuration>

这里的关键是你可以设置文件编码,或者你可以打开静态页面,例如notepad ++,并使用你在数据库中使用的相同编码保存它们。



BTW,你应该使用UTF8_Unicode_CI代替UTF8_General_CI,因为它在排序时只减慢了约10%但是对于双字节字符正确地执行了

The key here is that you can set the file encoding, alternatively you can open the static pages in for example notepad++ and save them using the same encoding as you use in the database.

BTW, you should use UTF8_Unicode_CI instead of UTF8_General_CI as it's only about 10% slower when sorting but does it correctly for doublebyte characters


这篇关于charset conflict db vs frontend的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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