Skip to content

Commit b2dee98

Browse files
committed
Replace control codes
1 parent 66323d4 commit b2dee98

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

autoload/webapi/json.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function! webapi#json#encode(val)
106106
return a:val
107107
elseif type(a:val) == 1
108108
let json = '"' . escape(a:val, '\"') . '"'
109+
let json = substitute(json, '\([[:cntrl:]]\)', '\=printf("\x%02d", char2nr(submatch(1)))', 'g')
109110
let json = substitute(json, "\r", '\\r', 'g')
110111
let json = substitute(json, "\n", '\\n', 'g')
111112
let json = substitute(json, "\t", '\\t', 'g')

0 commit comments

Comments
 (0)