Closed keineahnung2345 closed 3 years ago
I've found that in: https://github.com/xelkano/redmine_xapian/blob/fedf924a377dbb89b866f645428ee9aafe9207eb/lib/redmine_xapian/xapian_search.rb#L77-L79
query_string
is UTF-8, but query.description
is ASCII-8BIT
, but I can't find related information in xapian's website.
When I search the text "判断" in my document, it shows the following result:
I've found that's because in the following lines:
https://github.com/xelkano/redmine_xapian/blob/fedf924a377dbb89b866f645428ee9aafe9207eb/lib/redmine_xapian/xapian_search.rb#L196-L198
dochash[:sample].encoding
is ASCII-8BIT, which should be UTF-8 instead. After I changeddochash[:sample].encode('UTF-8', dochash[:sample].encoding, ...)
intodochash[:sample].encode('UTF-8', 'UTF-8', ...)
, the search result becomes normal:But it's just a workaround, and I don't know why
dochash[:sample]
is detected as ASCII-8BIT encoding. Is there a better fix? Thanks.