Skip to content

Commit 84b173f

Browse files
committed
Use new nr2char if possible
1 parent dff01d2 commit 84b173f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

autoload/webapi/json.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ function! webapi#json#decode(json)
7575
endif
7676
let json = substitute(json, '\n', '', 'g')
7777
let json = substitute(json, '\\u34;', '\\"', 'g')
78-
let json = substitute(json, '\\u\(\x\x\x\x\)', '\=s:nr2enc_char("0x".submatch(1))', 'g')
78+
if v:version >= 703 && has('patch780')
79+
let json = substitute(json, '\\u\(\x\x\x\x\)', '\=nr2char(str2nr(submatch(1), 16), 1)', 'g')
80+
else
81+
let json = substitute(json, '\\u\(\x\x\x\x\)', '\=s:nr2enc_char("0x".submatch(1))', 'g')
82+
endif
7983
if get(g:, 'webapi#json#allow_nil', 0) != 0
8084
let tmp = '__WEBAPI_JSON__'
8185
while 1

0 commit comments

Comments
 (0)