Using Pleco Dictionaries in Apple’s iOS Books app

DavidMars

进士
I am reading the iOS Books version of Heisig’s Remembering Simplified Hanzi. When I click on a word I can look it up in Apple’s dictionary. I can ‘manage’ the dictionaries to include Apple’s Traditional or Apple’s Simplified Chinese, French, Spanish, etc. But I don’t seem to be able to link to Pleco and, for example, Outlier in Pleco. Can this be done? If so, is it an iOS setting or a Pleco setting? Thanks, David Mars
 

DavidMars

进士
Alex, thanks for this. I tried to set up the shortcut and it seems to be about 90% of the way there. I have it accepting Text and Rich Text, I copy something in Notes, it opens Pleco, and then Pleco says it cannot handle the document type. I attach two screen shots, one outlining the shortcut & the other showing the Pleco rejection. Any thoughts? Thanks, David
2A1DD266-AD8D-496E-B8FF-416C2796BB69.jpeg
8753F264-654C-4F9C-99C9-A2E889A6F4EE.png
 
Alex, thanks for this. I tried to set up the shortcut and it seems to be about 90% of the way there. I have it accepting Text and Rich Text, I copy something in Notes, it opens Pleco, and then Pleco says it cannot handle the document type. I attach two screen shots, one outlining the shortcut & the other showing the Pleco rejection. Any thoughts? Thanks, DavidView attachment 3147View attachment 3148
I think the key is to enable the proper share sheet type:Rich text,Text. But it appears that you have that. This is what mine looks like. Maybe try to copy text from somewhere else and try that.

1573659689771.png
 
I noticed that you sent the text via Notes. I also tried using Notes, and it worked for me:
1573665086642.png

As a matter of fact, the first time I sent the text, it asked for the Encoding, but the second time, it went straight into Pleco:

1573665332467.png
 

DavidMars

进士
Alex, it doesn’t work from Notes or from Safari. I am thinking that the characters are basically Text and the Rich Text is only for formatting like Bold, Italics, etc.? Would it reduce my possible problems to set up the shortcut with just Text? I see that there is a Gallery of shortcuts. Is there any way to share your shortcut? Thanks, David
 

DavidMars

进士
Alex, thanks very much for that link. I set up Shortcuts to allow Untrusted Shortcuts. I deleted my Pleco shortcut efforts. I installed your shortcut on both my iPad & my iPhone. Both devices are running the latest version of Pleco & the latest version of iOS. I get the same error message - “File Added - Your new file could not be opened by our document reader and/or OCR modules, but it can be accessed via the “Inbox” folder in the “File Manager”. I presume we don’t need the OCR module or the document reader for this shortcut? I do have the Optical Character Recognizer installed, but not the Document Reader, which I’m happy to pay for if it would get this shortcut working, but don’t otherwise need. Thanks for your patience on this! Cheers, David 大卫
 

DavidMars

进士
Alex, I am now the proud owner of the Document Reader Add-On and a functioning Pleco Shortcut, many thanks. BTW, it keeps asking me to pick the encoding. Will it eventually learn? For standard simplified characters am I looking at using UTF-8? Or UTF-16 (LE) or UTF-16 (BE) or GB-18030 or Big5 HKSCS? Cheers, David 大卫
 

DavidMars

进士
It seems to only work with UTF-8 but ’locking‘ that in with the Settings in Document Reader doesn’t seem to avoid the need to choose UTF-8 every time.
 
Alex, I am now the proud owner of the Document Reader Add-On and a functioning Pleco Shortcut, many thanks. BTW, it keeps asking me to pick the encoding. Will it eventually learn? For standard simplified characters am I looking at using UTF-8? Or UTF-16 (LE) or UTF-16 (BE) or GB-18030 or Big5 HKSCS? Cheers, David 大卫
Most of the time it always asks. I'm always left with having to choose the encoding - except if I try to send the same text twice to Pleco, it doesn't ask the second time. I think if you send text that is already in its history list (clipboard), it will not ask.

I use UTF-8, since that is pretty much the standard encoding that is prevalent when text contains ASCII characters (they will encode in 8 bits). Chinese characters will encode in 2 or 3 bytes for UTF-8. For UTF-16, Chinese characters will encode to 2 bytes most of the time, so if text is mostly in an Asian language, UTF-16 will take less space. See the Wikipedia entry on UTF-8 for more detailed info: https://en.wikipedia.org/wiki/UTF-8.

You can change the text encoding once the reader comes up, in case you made a mistake, but I don't see a way of "locking" or defaulting the text encoding (under Settings->Modules->Reader in the main menu). It would be nice if they offered a way to do that, since you can always change it to something else later.
 
Last edited:

mikelove

皇帝
Staff member
Best way to avoid that would be to put a Byte Order Mark (BOM) at the front of your text file - most text editors should include the option to save UTF-8 or UTF-16 with one of those. With that in place, Pleco should detect the format automatically.
 
Best way to avoid that would be to put a Byte Order Mark (BOM) at the front of your text file - most text editors should include the option to save UTF-8 or UTF-16 with one of those. With that in place, Pleco should detect the format automatically.
Thanks for the suggestion. Doing text manipulation by adding the BOM in Shortcuts is tedious, it was much easier to insert the selected text into an HTML file (which specifies UTF-8) and then converting the the HTML to Rich Text to sent to Pleco. Here is a snippet of the Shortcut:

1573750584888.png


And here is a link to the newly created shortcut: https://www.icloud.com/shortcuts/f542ffd71e3e4984af97440353af58b4

I also want to point out that, although there is a font size in the HTML code, it doesn't seem to affect the size of the text displayed in Pleco. On an iPhone the text is very small. If I have a chance, I'll investigate this further.
 
Last edited:

DavidMars

进士
Alex, outstanding, thanks a lot. The text on my iPad is small, and as you say the text on the iPhone is very small. Cheers, David 大卫
 

DavidMars

进士
Alex, I was playing around with Shortcuts hoping to find some way to add further steps to your Copy To Pleco shortcut so that Shortcuts would Copy the Document contents (presumably the same as the Clipboard from the originating app) and then ‘manipulate’ the text more or less within Pleco to enlarge it to some fixed font size (22 or whatever) and then paste it back in. I thought this might be a workaround to whatever is ‘shrinking’ the clipboard text when it ‘lands’ in Pleco’s Document Reader. But I couldn’t find anything to do the trick - however I’m a Newbie at Shortcuts. I thought I’d see if this line of attack was of any use to get the Document Reader output at a legible size. Cheers, David
 
Alex, I was playing around with Shortcuts hoping to find some way to add further steps to your Copy To Pleco shortcut so that Shortcuts would Copy the Document contents (presumably the same as the Clipboard from the originating app) and then ‘manipulate’ the text more or less within Pleco to enlarge it to some fixed font size (22 or whatever) and then paste it back in. I thought this might be a workaround to whatever is ‘shrinking’ the clipboard text when it ‘lands’ in Pleco’s Document Reader. But I couldn’t find anything to do the trick - however I’m a Newbie at Shortcuts. I thought I’d see if this line of attack was of any use to get the Document Reader output at a legible size. Cheers, David
The only thing I found that would enlarge the text was to surround the <span …>…<\span> with a header mark. Actually the <span> doesn't seem to affect the the font size or type, so you can just replace the line with <h1>(Shortcut Input)<\h1>. This will make the text the size of a Header which also bolds the text. It's much more usable this way, although it it's bolded.

Also, if you look at the clipboard history, you'll see that text is being sent as HTML. So how the HTML is interpreted is up to Pleco.
 
Last edited:

DavidMars

进士
Alex, works great on my iPad. My iPhone still shows the text as pretty small but it is very workable. Thanks again, this is a nice improvement. Cheers, David
 
Top