函数参考


_SQLite_Encode

二进制编码一个字符串,数字或二进制数据作为用于 SQLite 查询的BLOB来源.

#include <SQLite.au3>
_SQLite_Encode ( $vData )

参数

$vData 要进行编码的数据 (字符串, 数字或二进制)

返回值

成功: 返回编码后的字符串
失败: 返回空字符串 并设置 @error 到 1

注意/说明

已编码的字符串使用单引号包围.
例如 chr(0) & chr(1) 编码后为 X'0001'
编码后的字符串可以使用 Sqlite 解码,并作为BLOB存储为二进制状态.
一个字符串可以使用_SQLite_Escape()储存为文本(TEXT)
一个数值同样可以这样存储,使用简单的链接

相关

_SQLite_Escape

示例/演示


#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hFile, $vData, $sFileName, $sData, $hQuery, $aRow, $sMsg
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE IF NOT EXISTS Test (data blob);")
$vData = Binary("Hello" & Chr(0) & "World"); = 48656C6C6F00576F726C64
$sData = _SQLite_Encode($vData)
_SQLite_Exec(-1, "INSERT INTO Test VALUES (" & $sData & ");")
$vData = Binary(Chr(0) & @CRLF); = 000D0A
$sData = _SQLite_Encode($vData)
_SQLite_Exec(-1, "INSERT INTO Test VALUES (" & $sData & ");")
$vData = Binary(Chr(0)); = 00 不过它被解释为数字并返回 0000000000000000
$sData = _SQLite_Encode($vData)
_SQLite_Exec(-1, "INSERT INTO Test VALUES ( " & $sData & " );")
_SQLite_Query(-1, "SELECT * FROM Test;", $hQuery)
While _SQLite_FetchData($hQuery, $aRow, 1) = $SQLITE_OK
    $sMsg &= Hex($aRow[0]) & @CR
WEnd
MsgBox(4096, "Result", $sMsg)
_SQLite_Close()
_SQLite_Shutdown()