incremental_search

incremental_search

Hiki添付のincremental_searchだと検索結果が文字化けしてしまうので、searchメソッドを以下の二箇所だけ修正しました。

header['charset'] = 'UTF-8'#'EUC-JP'

#print r
print euc_to_utf8( r )

の所です。

    def search
      word = utf8_to_euc( @cgi.params['key'][0] )
      r = ""
      unless word.empty? then
        total, l = @db.search( word )
        if @conf.hilight_keys
          l.collect! {|p| @plugin.make_anchor("#{@conf.cgi_name}?cmd=view&p=#{p[0].escape}&key=#{word.split.join('+').escape}", @plugin.page_name(p[0])) + " - #{p[1]}"}
        else
          l.collect! {|p| @plugin.hiki_anchor( p[0].escape, @plugin.page_name(p[0])) + " - #{p[1]}"}
        end
        if l.size > 0 then
          r = "<ul>\n" + l.map{|i| "<li>#{i}</li>\n"}.join + "</ul>\n"
        end
      end
      header = Hash::new
      header['type'] = 'text/html'
      header['charset'] = 'UTF-8'#'EUC-JP'
      header['Content-Language'] = @conf.lang
      header['Pragma'] = 'no-cache'
      header['Cache-Control'] = 'no-cache'
      print @cgi.header( header )
      #print r
      print euc_to_utf8( r )
      nil
    end