【发布时间】:2017-10-26 09:34:39
【问题描述】:
参考之前提出的关于 extracting the decimal value from a Z3 string 的 SO 问题,我知道 将 BitVec8 转换为一个字符串是可能的。例如,运行这个查询:
(declare-const s String)
(declare-const someBV8 (_ BitVec 8))
(assert (= (str.len s) 6))
(assert (= someBV8 #x62))
(assert (= (seq.unit someBV8) (str.at s 2)))
(assert (= (seq.unit someBV8) (str.at s 3)))
(assert (= (seq.unit someBV8) (str.at s 4)))
(check-sat)
(get-value (s))
给出以下输出:
sat
((s "\x00\x00bbb\x00"))
我想知道相反的转换是否也存在? 是否可以将一个字符串转换为 BitVec8? 类似 str2bv 的东西:
(declare-const s String)
(declare-const someBV8 (_ BitVec 8))
(assert (= (str.len s) 6))
(assert (= someBV8 #x62))
(assert (= someBV8 (str2bv (str.at s 2))))
(assert (= someBV8 (str2bv (str.at s 3))))
(assert (= someBV8 (str2bv (str.at s 4))))
(check-sat)
(get-value (s))
【问题讨论】: