px普贤教程PuXian
普贤教程 › 包参考

percent 包

URL 百分号编码(RFC 3986)

项值
包名percent
版本0.2.0
可用版本0.1.0 / 0.2.0
入口percent.px
分类网络与协议
文件数 / 行数1 / 131

安装与引入

bash
pxpkg init          # 首次
pxpkg add percent@0.2.0
pxpkg install
px
import percent
所属分类教程:网络与协议

公开接口

函数参数
percent_encodes, safe=""
percent_decodes
其余 10 个 def(内部与辅助,可直接调用但不属稳定接口)
函数参数
pc_is_alnumc
pc_is_unreservedc
pc_hex2n
pc_hexvalc
percent_encode_paths
percent_encode_querys
percent_encode_kvkey, val
percent_encode_paramspairs
percent_is_encodeds
percent_decode_forms

包内说明(源码头注释)

text
============================================================
普贤生态库:registry/percent —— URL 百分号编码(RFC 3986)
------------------------------------------------------------
纯函数库(无 IO、无状态),编译(px build)与解释(px run)双模式一致。
percent_encode(s, safe="") → Ok(str) | Err   按 UTF-8 字节 %XX 编码
percent_decode(s)          → Ok(str) | Err   %XX → UTF-8;非法转义 Err
保留字符:RFC 3986 unreserved(A-Z a-z 0-9 - _ . ~)+ 调用方 safe 集;
其余(含中文、空格、/ ? & = 等)一律 %XX 大写。
============================================================