什么是 HTML 实体编码?
HTML 实体编码是将特殊字符转换为 HTML 实体引用的过程。例如,< 转换为 <,& 转换为 &。这在防止 XSS 攻击和确保 HTML 正确显示方面非常重要。
本工具支持三种编码方式:
- 命名实体编码:使用 HTML 命名实体,如
<、©,可读性更好 - 数字实体编码:使用 Unicode 码点,如
<、©,覆盖所有字符 - 解码:将 HTML 实体还原为原始字符
常见使用场景:在 HTML 中显示代码片段、防止用户输入被解析为 HTML 标签、处理特殊符号和国际化字符。
What is HTML Entity Encoding?
HTML entity encoding converts special characters to HTML entity references. For example, < becomes <, and & becomes &. This is essential for preventing XSS attacks and ensuring correct HTML display.
This tool supports three encoding methods:
- Named Entity Encoding — Uses HTML named entities like
<,©for better readability - Numeric Entity Encoding — Uses Unicode code points like
<,©to cover all characters - Decoding — Converts HTML entities back to their original characters
Common use cases: displaying code snippets in HTML, preventing user input from being parsed as HTML tags, handling special symbols and internationalized characters.