fix issue with double backslash
This commit is contained in:
parent
9525c64917
commit
9ec05b3aba
1 changed files with 18 additions and 9 deletions
27
lib/utils.ml
27
lib/utils.ml
|
@ -1,15 +1,24 @@
|
||||||
let get_bytecode ?(json = false) data =
|
let get_bytecode ?(json = false) data =
|
||||||
let backslash = if json then "\\\\" else "\\" in
|
let backslash = '\\' in
|
||||||
let result =
|
let result =
|
||||||
List.map
|
String.concat
|
||||||
(fun byte ->
|
""
|
||||||
let code = Char.code byte in
|
(List.map
|
||||||
if code >= 65 && code <= 122
|
(fun byte ->
|
||||||
then String.make 1 byte
|
let code = Char.code byte in
|
||||||
else Printf.sprintf "%sx%02X" backslash code)
|
if code >= 65 && code <= 122
|
||||||
(List.of_seq (Bytes.to_seq data))
|
then String.make 1 byte
|
||||||
|
else Printf.sprintf "%cx%02X" backslash code)
|
||||||
|
(List.of_seq (Bytes.to_seq data)))
|
||||||
in
|
in
|
||||||
String.concat "" result
|
if json
|
||||||
|
then
|
||||||
|
String.concat
|
||||||
|
""
|
||||||
|
(List.map
|
||||||
|
(fun c -> if c = backslash then String.make 2 c else String.make 1 c)
|
||||||
|
(List.of_seq (String.to_seq result)))
|
||||||
|
else result
|
||||||
;;
|
;;
|
||||||
|
|
||||||
let get_obj_size obj = Obj.size (Obj.repr obj)
|
let get_obj_size obj = Obj.size (Obj.repr obj)
|
||||||
|
|
Reference in a new issue