Skip to main content

Appendix A. Static Dictionary Data (静态字典数据)

官方英文原文 (Official English Text)

This appendix contains the static dictionary data used by Brotli compression. The static dictionary consists of predefined words and phrases that commonly appear in web content.

For the complete static dictionary data, please refer to:

Official Source:

  • Text Format: https://www.rfc-editor.org/rfc/rfc7932.txt (Appendix A, lines ~2500-6500)
  • HTML Format: https://datatracker.ietf.org/doc/html/rfc7932#appendix-A

Implementation Reference:

  • Brotli Official Repository: https://github.com/google/brotli
  • Dictionary Files: c/common/dictionary.c and c/common/dictionary.h

Key Information:

The static dictionary contains:

  • Dictionary Size: 13,504 base words
  • Word Length Range: 4 to 24 bytes
  • Total Size: Approximately 122 KB
  • Optimized for: HTML, CSS, JavaScript, and common web protocols
  • Transformations: 121 predefined transformations (see Appendix B)

Structure:

The dictionary is organized into three components as described in Section 8:

  1. DICT[0..DICTSIZE]: Array of bytes containing all base words
  2. DOFFSET[0..24]: Byte-offset values for each length
  3. NDBITS[0..24]: Bit-depth values for each length

Usage:

As specified in Section 8, each base word can be transformed using 121 different transformations, resulting in:

Total dictionary entries = 13,504 × 121 = 1,634,984 possible words

Note: Due to the large size of the static dictionary data (approximately 4,000 lines of hexadecimal data), it is not reproduced in full here. Implementers should refer to the official RFC document or the Brotli reference implementation for the complete dictionary data.


中文翻译 (Chinese Translation)

本附录包含 Brotli 压缩使用的静态字典数据 (Static Dictionary Data)。静态字典由预定义的词和短语组成,这些词和短语通常出现在 Web 内容中.

完整静态字典数据的获取方式:

官方来源:

  • 文本格式: https://www.rfc-editor.org/rfc/rfc7932.txt(附录 A,第 44 页起,约第 2500-6500 行)
  • HTML 格式: https://datatracker.ietf.org/doc/html/rfc7932#appendix-A

实现参考:

  • Brotli 官方仓库: https://github.com/google/brotli
  • 字典文件: c/common/dictionary.cc/common/dictionary.h

关键信息:

静态字典包含:

  • 字典大小 (Dictionary Size): 13,504 个基本词 (Base Words)
  • 词长度范围 (Word Length Range): 4 到 24 字节
  • 总大小 (Total Size): 约 122 KB
  • 优化目标 (Optimized For): HTML、CSS、JavaScript 和常见 Web 协议
  • 变换数量 (Transformations): 121 种预定义变换(见附录 B)

结构 (Structure):

如第 8 节所述,字典组织为三个组件:

  1. DICT[0..DICTSIZE]: 包含所有基本词的字节数组 (Array of Bytes)
  2. DOFFSET[0..24]: 每个长度的字节偏移值 (Byte-Offset Values)
  3. NDBITS[0..24]: 每个长度的位深度值 (Bit-Depth Values)

使用方式 (Usage):

如第 8 节所规定,每个基本词可以使用 121 种不同的变换进行转换,产生:

总字典条目数 = 13,504 × 121 = 1,634,984 个可能的词

数据组织示例:

按长度组织的基本词数量(示例):

长度    位深度    词数量
---- ------ ------
4 6 64
5 6 64
6 6 64
...
24 (具体值) (具体数量)

注意: 由于静态字典数据的规模很大(约 4,000 行十六进制数据),此处未完整复制。实现者应参考官方 RFC 文档或 Brotli 参考实现以获取完整的字典数据.

关键特性

词汇覆盖范围:

  • Web 协议: HTTP 头部、MIME 类型、状态码
  • HTML: 常见标签、属性名称
  • CSS: 属性名、选择器
  • JavaScript: 关键字、常用函数名
  • 通用文本: 常见英文单词和短语

变换机制:

  • 121 种变换组合:前缀 + 基本变换 + 后缀
  • 21 种基本变换(Identity、FermentFirst、FermentAll、OmitFirst1-9、OmitLast1-9)
  • 每个基本词可生成多达 121 个变体

性能优化:

  • 针对 Web 内容的统计特性优化
  • 显著提高 HTML、CSS、JavaScript 文件的压缩率
  • 减少需要编码的字面量数量

实现建议:

  1. 在编译时嵌入静态字典数据
  2. 使用预计算的偏移表加速查找
  3. 缓存常用变换结果
  4. 对于资源受限环境,可以使用子集字典

来源 (Source): RFC 7932, Appendix A
官方文本 (Official Text): https://www.rfc-editor.org/rfc/rfc7932.txt
完整数据获取: 见官方 RFC 文档或 Brotli GitHub 仓库