From 4757aae967f47077da352b7872e51be6882813f2 Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 8 May 2013 09:28:33 +0900 Subject: [PATCH] Use meta charset. This may occur some problem. For example charset=Windows-31J won't work correctly. --- autoload/zencoding/util.vim | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/autoload/zencoding/util.vim b/autoload/zencoding/util.vim index ebc3a4b..6608782 100644 --- a/autoload/zencoding/util.vim +++ b/autoload/zencoding/util.vim @@ -146,10 +146,17 @@ endfunction "============================================================================== function! zencoding#util#getContentFromURL(url) let res = system(printf("%s %s", g:zencoding_curl_command, shellescape(substitute(a:url, '#.*', '', '')))) - let s1 = len(split(res, '?')) - let utf8 = iconv(res, 'utf-8', &encoding) - let s2 = len(split(utf8, '?')) - return (s2 == s1 || s2 >= s1 * 2) ? utf8 : res + let charset = matchstr(res, ']\+content=["''][^;"'']\+;\s\+charset=\zs[^;"'']\+\ze["'']>') + if len(charset) == 0 + let charset = matchstr(res, ']\+>') + endif + if len(charset) == 0 + let s1 = len(split(res, '?')) + let utf8 = iconv(res, 'utf-8', &encoding) + let s2 = len(split(utf8, '?')) + return (s2 == s1 || s2 >= s1 * 2) ? utf8 : res + endif + return iconv(res, charset, &encoding) endfunction function! zencoding#util#getTextFromHTML(buf)