Requests_IDNAEncoder
云策文档标注
概述
Requests_IDNAEncoder 是一个用于 IDNA URL 编码的类,提供 Punycode 编码和 ASCII 转换功能,但当前 nameprep 实现不完整,不完全符合规范。
关键要点
- 类名:Requests_IDNAEncoder,用于处理 IDNA 编码相关任务。
- 主要方法包括 encode、to_ascii、punycode_encode 等,支持主机名编码和 UTF-8 到 ASCII 的转换。
- 注意事项:nameprep 方法目前未完全实现,可能影响 IDNA 规范的完全合规性。
- 参考规范:RFC3490(IDNA 规范)和 RFC3492(Punycode/Bootstrap 规范)。
原文内容
IDNA URL encoder
Description
Note: Not fully compliant, as nameprep does nothing yet.
See also
- https://tools.ietf.org/html/rfc3490: IDNA specification
- https://tools.ietf.org/html/rfc3492: Punycode/Bootstrap specification
Methods
| Name | Description |
|---|---|
| Requests_IDNAEncoder::adapt | Adapt the bias |
| Requests_IDNAEncoder::digit_to_char | Convert a digit to its respective character |
| Requests_IDNAEncoder::encode | Encode a hostname using Punycode |
| Requests_IDNAEncoder::is_ascii | Check whether a given string contains only ASCII characters |
| Requests_IDNAEncoder::nameprep | Prepare a string for use as an IDNA name |
| Requests_IDNAEncoder::punycode_encode | RFC3492-compliant encoder |
| Requests_IDNAEncoder::to_ascii | Convert a UTF-8 string to an ASCII string using Punycode |
| Requests_IDNAEncoder::utf8_to_codepoints | Convert a UTF-8 string to a UCS-4 codepoint array |