跳到主要内容
uencoder

Charset

字符集(charset)是字符到码点的映射表,与编码形式(如 UTF-8)共同决定文本如何转为字节流。

用途

为字符与数字之间建立对应关系,使计算机能存储、传输与渲染文字。

机制

字符集定义字符与码点的映射(如 Unicode 码点 U+4E2D 对应汉字中);编码形式定义码点到字节流的规则(如 UTF-8 用 3 字节)。HTTP Content-Type charset 参数声明编码形式。

用例

  • Web 页面字符编码声明
  • 数据库列字符集设置
  • 文件编码检测与转换
  • 协议文本字段编码

示例

  • 输入
    Content-Type: text/html; charset=utf-8
    输出
    The browser decodes the page as UTF-8

    Declaring the encoding form

常见错误

Confusing a character set (e.g., Unicode) with an encoding form (e.g., UTF-8)
Keep them distinct: the character set defines code points, the encoding form defines bytes

相关词条

相关工具

参考链接