URLs Scheme in Pleco

#1
Hello!
I don’t know if this is possible or if is implemented already.
I am using Pleco in my iPad Pro and taking notes with Ulysses in my Chinese classes. I am wondering if I can link in some way words that I am learning from my document in Ulysses to Pleco dictionary directly. Maybe using URL as link... I am not sure.

Maybe looks not very interesting feature, but have links mainly to listen the words I am learning in class directly in Pleco could be incredible for me and I think for anyone that takes notes in the iOS device.

I saw something about it in the forum, but is from 2011, so for sure is quite updated. With iOS 11 all the apps tend to be connected one wich other to maximize the productivity.

Thanks in advance for the feedback about this.
 

mikelove

皇帝
Staff member
#2
We actually do support URLs now, but they're pretty well hidden, as we've mostly put them in for the sake of third-party developers who write us about connecting to Pleco; the only documentation on them at the moment is buried in our version history:

http://iphone.pleco.com/manual/30200/vershist.html

Search for 'plecoapi' on that page and you'll see URLs to look up words, perform searches, and even download flashcard lists.
 
#4
HI Mike,

Yet another wonderful feature I didn't know about.

I just tried the following in an html file downloaded to my ipad and it worked
<a href="plecoapi://x-callback-url/s?q=wo3">lookup test</a>

but the following failed in that it appears that the Chinese character wasn't encoded/passed properly to pleco
<a href="plecoapi://x-callback-url/s?q=我">lookup test</a>

Any suggestions for what I should be doing to make the latter work correctly?
 
#5
Hi pdwalker,

I'll start by telling you what I know! You can convert the URL to ASCII (which is required by HTTP) using a tool such as the following:

https://meyerweb.com/eric/tools/dencoder/

The anchor element

<a href="plecoapi://x-callback-url/s?q=我">lookup test</a>

would then look like this: (just encoding the URL between the quotes)

<a href="plecoapi%3A%2F%2Fx-callback-url%2Fs%3Fq%3D%E6%88%91">lookup test</a>

It's all explained on this page: https://perishablepress.com/stop-using-unsafe-characters-in-urls/

I guess that this would work, as well, but isn't safe in all situations:

<a href="plecoapi://x-callback-url/s?q=%E6%88%91">lookup test</a>

When you prepare a HTML file manually, it's a bit cumbersome to have go through this two-step process. But if a Pleco query is done by another app, it doesn't matter, since this app can just automatically convert the UTF-8 string to percent notation before passing it to Pleco, which in turn will decode it automatically. In JavaScript, the built-in function that does the encoding seems to be called encodeURIComponent.
 
Last edited:
#6
Thanks Shun,

That answers my question.

Clearly that I was under the mistaken impression that urls supported UTF8. Apparently not and we're still in the ASCII dark ages.

Much appreciated!
 
#7
You’re very welcome! It could be that the browser converts special Unicode chars you enter in the address bar to percent notation internally, since there are now Unicode domain names, but here I‘m not really sure.
 
Top