unicode & umlauts

Niggemann, Bernd Bernd.Niggemann at uni-wh.de
Thu Jun 21 20:31:22 EDT 2018

Hi Eric,

it seems that urlEncode does not give the expected hex values for high ASCII characters. Yandex expects UTF8 hex values.

for example 

the german o-umlaut after urlEncode is 
which is ASCII 154 in the extended ASCII table

yandex expects 

that is the utf8-urlEncode form. I don't know if Livecode can do that, I could not get it to work.

however yandex also accepts "html" as format

in my limited testing with your modified code it worked for me with german umlauts, maybe it also works with chinese.

on mouseup
   local theText, tResult, targetText
   repeat with i = 1 to the number of lines in card field "source"
      put the htmlText of line i of cd fld "source" into theText
      replace "<p>" with "" in theText
      replace "</p>" with "" in theText
      put URLEncode((theText)) into theText
      put  \
            "https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20180527T091305Z.7f33f9fb3f66f0bb.d573f1d9a6336a981504916600c45f49255938b3&text="&theText&"&lang=de-en&format=html" \
            into tResult
      put URL tResult into tResult
      set the itemdelimiter to "["
      put the last item of tResult into targetText
      put targetText & return after cd fld "target"
   end repeat
end mouseup

Kind regards

> Eric wrote:
> What doesn't work is calling the Yandex api to translate and then send the translation to a livecode field. Even though I definitely have all the fonts for Chinese and German installed Yandex returns a bunch of question marks to the field. :/  
> Why is that? What must be done? Because yandex clearly send HTML readable characters since the apis work on the web. What must I do to the text returned? 

More information about the Use-livecode mailing list