unicode & umlauts

scott at elementarysoftware.com scott at elementarysoftware.com
Thu Jun 21 15:11:48 EDT 2018


Hello Eric,
Just an idea but for working with yandex, what if you textEncode and textDecode for the round trip. Like so:

on mouseup
   repeat with i = 1 to the number of lines in card field "source"
      put URLEncode(textEncode(line i of cd fld "source","UTF8")) 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" into tResult
      put URL tResult into tResult
      set the itemdelimiter to "["
      put the last item of tResult into targetText
      put textDecode(targetText,"UTF8") & return after cd fld "target"
   end repeat
end mouseup


Scott Morrow

Elementary Software
(Now with 20% less chalk dust!)
web       http://elementarysoftware.com/
email     scott at elementarysoftware.com
phone booth:  1-800-615-0867
------------------------------------------------------

> On Jun 21, 2018, at 8:42 AM, Eric A. Engle via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Yes, I think my problem with Chinese was I had only simplified and not traditional fonts installed. Anyway I installed some libraries now my paste clipboard ctrl v works.
> 
> 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? 
> 
> on mouseup
>  repeat with i = 1 to the number of lines in card field "source"
>      put URLEncode(line i of cd fld "source") 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" 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
> 
> This script works For German except it munges up umlauts. It also works for zh-en but then just returns a bunch of question marks. I definitely have all fonts installed. I have tried this in windows 10 and linux mint in case it is still a linux issue.
> 
> How am I to process this text from the yandex api to get unicode chinese characters? 
> 
> Another question: in hypercard cmd + . = stop executing script. Is there any similar command in livecode?
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode












More information about the use-livecode mailing list