# string.escape2 库模块帮助文档

[使用范例](https://www.aardio.com/zh-cn/docs/examples/Text/Crypt/escape2.html)

## string 成员列表 <a id="string" href="#string">&#x23;</a>

### string.escape2(str) <a id="string.escape2" href="#string.escape2">&#x23;</a>
如果参数指定 null 或空字符串时直接返回。  
如果参数指定 10 进制转义字符串，且以 `\0` 开始则先取消转义。  
如果字符串为  escape2 编码格式则解码后返回。  
其他普通字符串直接返回。

### string.escape2(str,'\0') <a id="string.escape2" href="#string.escape2">&#x23;</a>
将参数 str 指定的字符串 escape2 编码，并转换为 十进制转义格式后返回。  
返回的所有字符转换为`\ddd`转义格式，`ddd` 为 1 到 3 个 10 进制数字表示的字节码数值。  

此函数会将所有除`'\0'`以外的单字节字符作为参数 @keyByte 进行 escape2 编码，  
并返回长度最短的结果。  

参数 @str 为空字符串或 null 值时直接返回原参数。

### string.escape2(str,keyByte) <a id="string.escape2" href="#string.escape2">&#x23;</a>
将参数 str 指定的字符串 escape2 编码，并转换为 十进制转义格式后返回。  
返回的所有字符转换为`\ddd`转义格式，`ddd` 为 1 到 3 个 10 进制数字表示的字节码数值。  
参数 @str 为空字符串或 null 值时直接返回原参数。   

参数 @keyByte 必须指定单个单字节字符。

## string.escape2 成员列表 <a id="string.escape2" href="#string.escape2">&#x23;</a>

生成或还原 escape2 格式字符串，可兼容普通字符串。  
将普通的字符串作为唯一参数就会直接返回。  
将 escape2 编码的字符串作为唯一参数会复原后再返回。

### string.escape2.escape() <a id="string.escape2.escape" href="#string.escape2.escape">&#x23;</a>
如果参数指定的字符串第一个字节码为 0 则转换为转义字符串。  
所有字符转换为`\ddd`格式，`ddd` 为 1 到 3 个 10 进制数字表示的字节码数值。

### string.escape2.unescape() <a id="string.escape2.unescape" href="#string.escape2.unescape">&#x23;</a>
如果参数指定 10 进制转义字符串，  
且以 `\0` 开始则取消转义，  
否则返回原参数。  

此函数不会进行 string.escape2 解码。
