charset
它能做什么
这项技能检查 HTML 页面是否在文档靠前的位置声明了字符编码。适合希望任何语言的文字都能正确显示的开发者。
适用场景
- ✓当页面显示乱码,例如重音字符或符号错误时。
- ✓当你新建一个 HTML 模板时。
- ✓当你审查页面的 head 部分是否设置正确时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/charset/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我的页面模板是否尽早声明了 UTF-8,以确保特殊字符能正确显示。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会在页面 head 的第一个元素位置添加 charset 设为 UTF-8 的 meta 标签,并确保它位于文档的前 1024 个字节之内。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Declare UTF-8 character encoding
Missing or incorrect charset causes mojibake (garbled text), broken special characters, and security vulnerabilities from character encoding attacks.
Quick Reference
- Add
<meta charset="UTF-8">as the first element in <head> - Must appear within the first 1024 bytes of the document
- UTF-8 supports all languages and special characters
Check
Verify that this HTML document declares UTF-8 character encoding in the head section and that it's positioned early in the document.
Fix
Add <meta charset="UTF-8"> as the first meta tag in the head section of the HTML document.
Explain
Explain why UTF-8 character encoding is essential for international content support and preventing character display issues.
Code Review
Review templates, server-rendered HTML, and shared components that output markup related to Declare UTF-8 character encoding. Flag exact elements, attributes, and routes where the rendered HTML violates the rule.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
常见问题
什么是乱码(mojibake)?
这项技能用这个词指代字符被以错误的编码读取时出现的乱码文字。
为什么声明必须靠前?
这项技能说明,它必须出现在文档的前 1024 个字节之内。
UTF-8 支持所有语言吗?
这项技能说明,UTF-8 支持所有语言和特殊字符。
详情
作者的原始描述
Use when reviewing templates, rendered HTML, or shared components related to Declare UTF-8 character encoding. Validate the final browser-facing markup, not just the source framework abstraction.
热度
- GitHub 星标
- 75k
- 排名
- #2771
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。