[luatex] UTF-16 with pdfe.getstring()

Andreas Matthias andreas.matthias at gmail.com
Wed Mar 17 17:30:38 CET 2021


I'm having a hard time with pdfe.getstring(). What am I supposed to do if it
returns an UTF-16 encoded string? How to convert it to UTF-8?

Here is what I'm actually trying to do: I'm reading the /Contents of a
Text-Annotation
with pdfe.getstring(). The returned string happens to be UTF-16
encoded. Now I want to
use this string to create a pdf_annot whatsit. Of course this doesn't work:

This is LuaTeX, Version 1.13.0 (TeX Live 2021/dev)
 restricted system commands enabled.
(./test.tex
! String contains an invalid utf-8 sequence.
l.17 }

I've attached an example to replicate this issue.

Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tex
Type: text/x-tex
Size: 477 bytes
Desc: not available
URL: <https://tug.org/pipermail/luatex/attachments/20210317/6ba3095a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.pdf
Type: application/pdf
Size: 5750 bytes
Desc: not available
URL: <https://tug.org/pipermail/luatex/attachments/20210317/6ba3095a/attachment.pdf>


More information about the luatex mailing list.