最近开发一个vue的小项目的时候,就碰到了这个问题,但其实HTML中已经设置了Utf-8编码方式,css中的中文仍然有概率会出现乱码
- css:
- 如上图,预期效果应该是显示中文 ‘开’:
解决办法
可以是直接把中文转为一串utf8编码,然后替换进去,下面我们来聊聊要怎么做。
- 在百度直接搜索 ‘在线中文转UTF8’,随便找一个网站:
- 这里就以 https://www.ip138.com/utf8/ 为例:
- 输入我们的中文字符串,然后点击转换,就可以得到一串UTF8编码:开
- 接下来把 开 前面的 &#x 和 末尾的分号 ; 去掉, 就只剩下 5F00,然后在前面加一个反斜杠 \ ,最终就得到了 \5F00
- 然后把它替换掉CSS中的中文字符串即可:
- 然后刷新一下网页,最好先清理一下浏览器的缓存,不然可能页面没有反应(浏览器缓存清理方法)
其他
- 有些网站转出来的可能不是 开 这个格式可能会是 %u5F00 ,还可能是 \u5F00 ;处理方式都是差不多的,把前面的 %u 或是 \u 删掉,并在前面添加反斜杠 \ 。
- 显然前缀都只是标记,为了去告诉计算机这是一个转义需要的UTF8编码,而不要输出为一串数字和字母,但在CSS中应使用反斜杠转义。
I couldn’t resist commenting. Very well written.
Hello there! I simply want to offer you a huge thumbs up for the great info you’ve got here on this post. I will be coming back to your blog for more soon.
Aw, this was an exceptionally good post. Taking the time and actual effort to make a superb article… but what can I say… I put things off a whole lot and don’t manage to get anything done.
Everything is very open with a really clear description of the challenges. It was truly informative. Your website is useful. Many thanks for sharing.
Aw, this was an exceptionally good post. Spending some time and actual effort to generate a great article… but what can I say… I put things off a lot and don’t seem to get nearly anything done.
Excellent post. I definitely appreciate this site. Stick with it!
The next time I read a blog, I hope that it does not disappoint me just as much as this one. After all, Yes, it was my choice to read through, nonetheless I genuinely thought you’d have something useful to talk about. All I hear is a bunch of moaning about something you can fix if you were not too busy seeking attention.
You have made some decent points there. I looked on the web for more info about the issue and found most people will go along with your views on this web site.
By the tip of 1940, over 9 hundred patients were staying at the institute, the level of staff kept falling resulting from men being known as as much as enlist and nurses going to assist within the battle.
“The Lord reigns, he is clothed with majesty; The Lord is clothed, He has girded Himself with strength.
At 2:01 a.m. on December 22, 1926, the passenger station at Passaic exploded and caught fire.
Martini intervened in the arguing, feeling that the Passaic Engineering Department was in charge of the Works Progress Administration initiatives and did not need further money for specialists in engineering and structure to determine their course of, something Blandino disagreed with.
Your doctor might inform you your little one won’t be poisoned from consuming pet food.
Richard George Rogers. For providers to Structure.
You can even invest in commodity futures or ETPs (Exchange Traded Merchandise), which monitor commodity indices.
GAMEPLAY: Every round players inform a truth or a lie depending on their assigned function.
Fine to medium density can benefit from a style that adds body by splitting off the part from one facet to the other.
John Henry Woodhouse, Distribution Foreman, Matlock Sub-Division, East Midlands Fuel Board.