Is there any disadvantage of using: text/plain; ch

2019-04-04 02:01发布

My web server serves content that is in 95% of the time just simple ascii. However in some rare cases, the content contains some German non-ascii characters.

Now I could set the content-type response header by detecting if the content contains any non-ascii characters, or I could just always set the response header:

Content-Type: text/plain; charset=UTF-8

Is there any disadvantage in doing the latter?

3条回答
不美不萌又怎样
2楼-- · 2019-04-04 02:31

No, there is no disadvantage -- but you'll need to spell "utf-8" correctly.

查看更多
再贱就再见
3楼-- · 2019-04-04 02:46

Nope, all it's there for is to tell the browser which character set to decode your response with.

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-04-04 02:50

ASCII is a subset of UTF-8, so it is perfectly safe to declare the charset as utf-8 for an all-ASCII document.

查看更多
登录 后发表回答