Text-Grab
Text-Grab copied to clipboard
If the OCR result is too long, Text Grab will fail to show the toast notification
Describe the bug
Here's a Microsoft blog that says:
The XML payload that you construct for your tile notifications must be no larger than 5 KB. Otherwise, you will get a COMException with HResult 0x803E0115 saying that "The size of the notification content is too large."
If the OCR area has enough text that makes the final XML bigger than 5 KB, an exception will be thrown when trying to show the toast notification.
To Reproduce
Try to OCR a screen full of Chinese text.
One Chinese character takes 3 bytes in UTF-8, and it's converted to hexadecimal text, which again doubles the character count. So if there are enough Chinese characters, the XML result will grow beyond 5 KB.
How this might be fixed
- Truncate the body text of the notification if it is too long. (Windows will truncate the text when showing the toast anyway)
- Use a more efficient encoding method such as base64 so that more bytes can be put in the XML.
- Or maybe use another way to pass the recognized text, for example, store those long results into temporary text files.