Skip to content

Instantly share code, notes, and snippets.

@mattn
Created December 5, 2011 07:17
Show Gist options
  • Save mattn/1432671 to your computer and use it in GitHub Desktop.
Save mattn/1432671 to your computer and use it in GitHub Desktop.
Index: twitvim.vim
===================================================================
--- twitvim.vim (revision 250)
+++ twitvim.vim (working copy)
@@ -327,7 +327,9 @@
let true = 1
let false = 0
let null = ''
- sandbox let result = eval(a:str)
+ let str = iconv(a:str, "utf-8", &encoding)
+ let str = substitute(str, '\\u\(\x\x\x\x\)', '\=s:nr2enc_char("0x".submatch(1))', 'g')
+ sandbox let result = eval(str)
return result
catch
call s:errormsg('JSON parse error: '.v:exception)
@@ -5189,9 +5191,10 @@
" Twitter Search API doesn't return in_reply_to_status_id_str yet, so work
" around this by hacking the JSON output.
- let output = substitute(output, '"in_reply_to_status_id":\(\d\+\)', '\0,"in_reply_to_status_id_str":"\1"', 'g')
-
let result = s:parse_json(output)
+ if !has_key(result, 'in_reply_to_status_id_str') && has_key(result, 'in_reply_to_status_id')
+ let result['in_reply_to_status_id_str'] = '' . result['in_reply_to_status_id']
+ endif
if error != ''
let errormsg = get(result, 'error', '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment