sending Unicode strings that include punctuation to search engines with revGoURL
Curt Ford
cford at sc.edu
Fri May 18 13:25:55 EDT 2007
My app allows users to send a word to a search engine for more
examples of usage. With help from the list I've gotten it to work
with languages using the Latin alphabet, Russian, even Hindi..
It does fail, though, when I send a search string in Russian that
includes any punctuation or space. For example, the search string for
ой! (a two-letter word followed by an exclamation mark) shows up in
the engines as http://www.google.com/search?q=%04%1E%049! .
Does anyone have suggestions on how to tweak this so terms like
'как-то' or 'потому что' can be sent to the search
engines?
Existing code:
When the user displays a new term, the word to search for is set up
like this:
on changeWord
global gWord, gWordToSearch
--use an invisible field so we can check its effectiveTextFont to
see if it's Unicode
set the HTMLText of fld "invisibleWordToSearch" to gWord
set the useUnicode to true
--if the field contains Unicode text..
if the effective textFont of word 1 of field
"invisibleWordToSearch" contains comma then
--next line works for Russian
put urlEncode(unidecode(fld "invisibleWordToSearch", utf8)) into
gWordToSearch
else
--next line works for Roman alphabet
put fld "invisibleWordToSearch" into gWordToSearch
end if
end changeWord
The 'search' button has this script:
on mouseUp
global gWordToSearch
revGoURL (the cSearchEngine of this stack & gWordToSearch)
end mouseUp
thanks
Curt
More information about the use-livecode
mailing list