@@ -78,7 +78,6 @@ function! s:_resolve(val, prefix) abort
78
78
return a: val
79
79
endfunction
80
80
81
-
82
81
function ! s: _vital_created (module) abort
83
82
" define constant variables
84
83
if ! exists (' s:const' )
@@ -114,6 +113,10 @@ function! s:decode(json, ...) abort
114
113
let json = join (split (json, " \n " ), ' ' )
115
114
let json = substitute (json, ' \\u34;' , ' \\"' , ' g' )
116
115
let json = substitute (json, ' \\u\(\x\x\x\x\)' , ' \=s:string.nr2enc_char("0x".submatch(1))' , ' g' )
116
+ " convert surrogate pair
117
+ let json = substitute (json, ' \([\uD800-\uDBFF]\)\([\uDC00-\uDFFF]\)' ,
118
+ \ ' \=nr2char(0x10000+and(0x7ff,char2nr(submatch(1)))*0x400+and(0x3ff,char2nr(submatch(2))))' ,
119
+ \ ' g' )
117
120
if settings.allow_nan
118
121
let [NaN,Infinity] = [s: float_nan ,s: float_inf ]
119
122
endif
@@ -122,7 +125,7 @@ function! s:decode(json, ...) abort
122
125
while stridx (json, prefix) != -1
123
126
let prefix .= ' _'
124
127
endwhile
125
- let [null,true,false] = map ([ ' null' ,' true' ,' false' ], ' prefix . v:val ' )
128
+ let [null,true,false] = [prefix. ' null' ,prefix. ' true' ,prefix. ' false' ]
126
129
sandbox return s: _resolve (eval (json), prefix)
127
130
else
128
131
let [null,true,false] = [s: const .null (),s: const .true (),s: const .false ()]
0 commit comments