On 2/9/2021 6:57 PM, Michal Vlasák wrote:
Hello,

conversion to UTF-16BE PDF strings used for example in bookmarks / PDF
outlines is not right.

Take the following example:

```
\starttext
\setupinteraction[state=start]
\placebookmarks[section][number=no]

\section[bookmark=𝕄]

\stoptext
```

Produces: <FEFF0075DD44> for 𝕄 (U+1D544), instead of the correct
<FEFFD835DD44>.


The relevant function is `lpdf.tosixteen()` (from lpdf-ini.lmt), and its
`cache`. (Although the same function is also in lpdf-aux.lmt, and in
MkIV equivalents).

My proposal (also enclosed as a file attachment):

```
--- a/lpdf-ini.lmt
+++ b/lpdf-ini.lmt
@@ -178,7 +178,8 @@
          if v < 0x10000 then
              v = format("%04x",v)
          else
-            v = format("%04x%04x",rshift(v,10),v%1024+0xDC00)
+            v = v - 0x10000
+            v = format("%04x%04x",rshift(v,10)+0xD800,v%1024+0xDC00)
          end
          t[k] = v
          return v
```

(Note the similiarity to existing function `big()` in l-unicode.lua.)

I found this by chance, but I am not really a ConTeXt user, so I hope
didn't miss anything.
Thanks for noticing (btw, the aux file is used on some scripts, not in context itself).

Hans

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
_______________________________________________
dev-context mailing list
dev-context@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-context

Reply via email to