TC官方文档翻译12----编码API(Tokyo Cabinet/Tokyo Tyarnt 文档系列)

/**
 * 转载请注明出处, 由于个人技术能力有限, 英语水平欠缺,
 * 有翻译不合适或错误的地方, 请纠正,
 * 希望不要因为我的错误误导您, 希望您的智慧可以加入.
 * @translator: selfimpr
 * @mail: [email protected]
 * @blog: http://blog.csdn.net/lgg201
 */

 

由于能力有限, 自己对TC的文件数据库部分尚未理解, 所以暂时到此为止.

 

 

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-fareast-font-family:宋体; mso-bidi-font-family:"Times New Roman"; mso-font-kerning:1.0pt;} p.MsoIntenseQuote, li.MsoIntenseQuote, div.MsoIntenseQuote {mso-style-priority:30; mso-style-unhide:no; mso-style-qformat:yes; mso-style-link:"明显引用 Char"; mso-style-next:正文; margin-top:10.0pt; margin-right:46.8pt; margin-bottom:14.0pt; margin-left:46.8pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; border:none; mso-border-bottom-alt:solid #4F81BD .5pt; padding:0cm; mso-padding-alt:0cm 0cm 4.0pt 0cm; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-fareast-font-family:宋体; mso-bidi-font-family:"Times New Roman"; color:#4F81BD; mso-font-kerning:1.0pt; font-weight:bold; font-style:italic;} span.Char {mso-style-name:"明显引用 Char"; mso-style-priority:30; mso-style-unhide:no; mso-style-locked:yes; mso-style-link:明显引用; mso-ansi-font-size:10.5pt; mso-bidi-font-size:11.0pt; color:#4F81BD; mso-font-kerning:1.0pt; font-weight:bold; font-style:italic;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt; mso-ascii-font-family:Calibri; mso-fareast-font-family:宋体; mso-hansi-font-family:Calibri; mso-font-kerning:0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.WordSection1 {page:WordSection1;} -->

编码 API

char *tcurlencode(const char *ptr, int size);

         使用 URL 编码规则编码一个序列化对象 .

char *tcurldecode(const char *str, int *sp);

         使用 URL 编码规则解码 str, sp 记录解码后返回值长度

TCMAP *tcurlbreak(const char *str);

         把个顶的 url 字符串 str 按照 URL 规则分裂成为一个 TCMAP 对象 , 返回的 TCMAP 对象中有以下 key:

         self: URL 自身

         scheme: 协议 , 支持 HTTP, HTTPS, FTP, FILE

         host: 主机名或 IP

         port: 主机端口号

         authority: 站点信息 ( 不是很清楚 , 有懂的朋友麻烦邮件 [email protected], 共同学习 , 谢谢 )

         path: 资源路径

         file: 访问文件名 ( 无目录 )

         query: 查询字符串

         fragment: url 最后的 # 后面的东西 , 通常是访问锚点 . BOM 中的 window.location.hash

char *tcurlresolve(const char *base, const char *target);

         用一个绝对路径的 URL 解析一个相对路径的 URL, 如果 target 是相对的 , 返回的是相对 base 的域的 URL, 否则返回 target 的拷贝 .

char *tcbaseencode(const char *ptr, int size);

         base64 编码一个序列化对象

char *tcbasedecode(const char *str, int *sp);

         base64 编码解码

char *tcquoteencode(const char *ptr, int size);

         Quoted-printable 编码一个序列化对象

char *tcquotedecode(const char *str, int *sp);

         Quoted-printable 编码解码

char *tcmimeencode(const char *str, const char *encname, bool base);

         MIME 编码 , encname 指定编码名字 , base 指定是否使用 base64 进行编码 , 如果是 false 使用 Quoted-printable 编码

char *tcmimedecode(const char *str, char *enp);

         MIME 解码 , 解码后 , enp 将会记录 tcmimeencode 中的 encname 类型名

char *tcmimebreak(const char *ptr, int size, TCMAP *headers, int *sp);

         ptr 给定的 MIME 内容拆分成 head body, body 作为函数的内容返回 , sp 将记录 body 的大小 , 对于拆分得到的头 , 组装成 TCMAP 记录到 headers , headers 中有如下 key

         TYPE: Content-Type

         CHARSET: Content-Transfer-Encoding

         BOUNDARY: Content-Type 标头的边界参数值

         DISPOSITION: MIME 协议的 Content-Disposition 标头

         FILENAME: 文件名

         NAME: 属性名

TCLIST *tcmimeparts(const char *ptr, int size, const char *boundary);

         根据 boundary 分割 ptr 指定的 MIME 数据为一个 TCLIST

char *tchexencode(const char *ptr, int size);

         把一个序列化对象编码成 16 进制 , 内部是没读取一个字节 , sprintf 输入到新的字符串中 , 最终返回新字符串

char *tcpackencode(const char *ptr, int size, int *sp);

         使用 Packbits 算法压缩序列化对象 , sp 记录压缩后大小

char *tcpackdecode(const char *ptr, int size, int *sp);

         使用 Packbits 算法解压缩

char *tcbsencode(const char *ptr, int size, int *sp);

         使用 TCBS 算法压缩序列化对象 , sp 记录压缩后大小

char *tcbsendecode(const char *ptr, int size, int *sp);

         使用 TCBS 算法解压

char *tcdeflate(const char *ptr, int size, int *sp);

         使用 Deflate 算法压缩序列化对象 , sp 记录压缩后大小

char *tcinflate(const char *ptr, int size, int *sp);

         使用 Deflate 算法解压缩

char *tcgzipencode(const char *ptr, int size, int *sp);

         gzip 压缩

char *tcgzipdecode(const char *ptr, int size, int *sp);

         gzip 解压缩

unsigned int tcgetcrc(const char *ptr, int size);

         获取 CRC32 校验和

char *tcbzipencode(const char *ptr, int size, int *sp);

         使用 BZIP2 压缩

char *tcbzipdecode(const char *ptr, int size, int *sp);

         BZIP2 解压缩

char *tcberencode(const unsigned int *ary, int anum, int *sp);

         使用 BER 编码一个无符号整数数组

unsigned int *tcberdecode(const char *ptr, int size, int *np);

         从一个字符串利用 BER 算法解码出一个无符号整数数组 , np 记录数组大小

char *tcxmlescape(const char *str);

         用来将给定的 xml 字符串 str 中的特殊字符 (xml 中定义的 ) 进行转义 , 该函数只会转义 ’&’, ‘<’, ‘>’, ‘”’ 4 个字符

char *tcxmlunescape(const char *str);

         将给定的 xml 字符串 str 中的实体字符 (xml 中定义的 ) 还原成原始字符 , 该函数只会转义 ’&amp;’, ‘&lt’, ‘&gt;’, ‘quot;’

你可能感兴趣的:(TC官方文档翻译12----编码API(Tokyo Cabinet/Tokyo Tyarnt 文档系列))