strip punctuations around word before searching

This should fix #1337.
This commit is contained in:
chrox
2015-02-01 17:40:34 +08:00
parent 3f691bab93
commit 07586cea71
3 changed files with 13 additions and 3 deletions

View File

@@ -59,9 +59,7 @@ end
function ReaderDictionary:stardictLookup(word, box)
DEBUG("lookup word:", word, box)
if word then
-- strip ASCII punctuation characters around selected word
-- and strip any generic punctuation (U+2000 - U+206F) in the word
word = word:gsub("\226[\128-\131][\128-\191]",''):gsub("^%p+",''):gsub("%p+$",'')
word = require("util").stripePunctuations(word)
DEBUG("stripped word:", word)
-- escape quotes and other funny characters in word
local std_out = io.popen("./sdcv --utf8-input --utf8-output -nj "..("%q"):format(word), "r")