リビジョン | a31c50000135a4d7994990cc8827dc0ba3cce06d (tree) |
---|---|
日時 | 2017-09-30 00:27:35 |
作者 | umorigu <umorigu@gmai...> |
コミッター | umorigu |
Improve EUC-JP handling
@@ -44,6 +44,7 @@ function plugin_search2_action() | ||
44 | 44 | } |
45 | 45 | } else if ($action === 'query') { |
46 | 46 | $text = isset($vars['q']) ? $vars['q'] : ''; |
47 | + header('Content-Type: application/json; charset=UTF-8'); | |
47 | 48 | plugin_search2_do_search($text, $base, $start_index); |
48 | 49 | exit; |
49 | 50 | } |
@@ -157,7 +158,15 @@ function plugin_search2_do_search($query_text, $base, $start_index) | ||
157 | 158 | 'next_start_index' => $readable_page_index + 1, |
158 | 159 | 'search_done' => $search_done, |
159 | 160 | 'results' => $found_pages); |
160 | - print(json_encode($result_obj, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); | |
161 | + $obj = $result_obj; | |
162 | + if (!defined('PKWK_UTF8_ENABLE')) { | |
163 | + if (SOURCE_ENCODING === 'EUC-JP') { | |
164 | + mb_convert_variables('UTF-8', 'CP51932', $obj); | |
165 | + } else { | |
166 | + mb_convert_variables('UTF-8', SOURCE_ENCODING, $obj); | |
167 | + } | |
168 | + } | |
169 | + print(json_encode(obj, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); | |
161 | 170 | } |
162 | 171 | |
163 | 172 | function plugin_search2_search_form($s_word = '', $type = '', $bases = array()) |
@@ -21,12 +21,14 @@ window.addEventListener && window.addEventListener('DOMContentLoaded', function( | ||
21 | 21 | '&': '&', |
22 | 22 | '"': '"', |
23 | 23 | '<': '<', |
24 | - '>': '>', | |
24 | + '>': '>' | |
25 | 25 | }[m]; |
26 | 26 | }); |
27 | 27 | } |
28 | 28 | function doSearch(searchText, session, startIndex) { |
29 | 29 | var url = './?cmd=search2&action=query'; |
30 | + var props = getSiteProps(); | |
31 | + url += '&encode_hint=\u3077'; | |
30 | 32 | if (searchText) { |
31 | 33 | url += '&q=' + encodeURIComponent(searchText); |
32 | 34 | } |