由於釋放10,PB是unicode(UTF-16LE)知曉。因此,傳統Len()
隱含LenW()
(如其他字符串函數,並處理遺留數據可能暗示使用明確的LenA()
)。
你確定你得到了一些utf-16le編碼?給定以下函數,如果用hexdump_blob(blob(your_string))
調用該函數,它將返回包含數據的字符串的內容?
將此代碼粘貼到名爲hexdump_blob
的新全局函數的源代碼中,以獲得blob內容的十六進制顯示(十六進制編輯器)。
global type hexdump_blob from function_object
end type
forward prototypes
global function string hexdump_blob (blob abl_data, boolean ab_fill_lastline)
end prototypes
global function string hexdump_blob (blob abl_data, boolean ab_fill_lastline);//hexify a blob content
string ls_tohex = "ABCDEF"
string ls_msg = "", ls_line, ls_binary
long i, j, length
byte b
string ls_fill
if isnull(abl_data) then return ""
if ab_fill_lastline then
ls_fill = " __"
else
ls_fill = " "
end if
length = len(abl_data)
for i = 1 to length
GetByte(abl_data, i, b)
ls_line += mid(ls_tohex, 1+ mod(int(b/16),16), 1)
ls_line += mid(ls_tohex, 1+ mod(b,16), 1)
ls_line += " "
ls_binary += string(iif(b>31 and b<128,char(b)," "))
if mod(i,16) = 0 and i > 0 then
ls_binary = replaceall(ls_binary, "~r", "·") //no cr/lf
ls_binary = replaceall(ls_binary, "~n", "·")
ls_binary = replaceall(ls_binary, "~t", "·")
ls_msg += "[" + string(i - 16, "0000") + "] " + ls_line + "~t" + ls_binary + "~r~n"
ls_line = ""
ls_binary = ""
end if
next
i -- // i - 1 due to the last loop in for
ls_line += fill(ls_fill, 3 * (16 - mod(i, 16)))
ls_msg += "[" + string(i - mod(i,16), "0000") + "] " + ls_line + "~t" + ls_binary
return ls_msg
end function
另外,這裏是replaceall()
函數所使用的hexdump_blob()
global type replaceall from function_object
end type
forward prototypes
global function string replaceall (string as_source, string as_pattern, string as_replace)
end prototypes
global function string replaceall (string as_source, string as_pattern, string as_replace);//remplace toute les occurences de as_pattern de as_source par as_replace
string ls_target
long i, j
ls_target=""
i = 1
j = 1
do
i = pos(as_source, as_pattern, j)
if i>0 then
ls_target += mid(as_source, j, i - j)
ls_target += as_replace
j = i + len(as_pattern)
else
ls_target += mid(as_source, j)
end if
loop while i>0
return ls_target
end function
和模擬的C三元運算符的iif()
,或視覺基本IIF()
global type iif from function_object
end type
forward prototypes
global function any iif (boolean ab_cond, any aa_true, any aa_false)
end prototypes
global function any iif (boolean ab_cond, any aa_true, any aa_false);
// simulates the VB iif or C ternary operator
if ab_cond then
return aa_true
else
return aa_false
end if
end function
因爲'莉娜()'是ANSI文本,我想這個OP不會有不同的結果。 – Seki
是的,不幸的是,LenA()不能用於我們正在尋找的東西。我們試圖用總視覺字符來計數,而不是用代碼單元來計算。 –