Hi, FYI \unprotect \mathchardef \utf@h=2048 \def\numbertoutf#1% {\ifnum#1<128 \rawcharacter{#1}% \else\ifnum#1<2048 \rawcharacter{\the\numexpr192+#1/64\relax}% \rawcharacter{\the\numexpr128+#1-(#1/64)*64\relax}% \else % 3 bytes \rawcharacter{\the\numexpr224+#1/4096\relax}% \rawcharacter{\the\numexpr128+(#1-(#1/4096)*4096)/128\relax}% \rawcharacter{\the\numexpr128+(#1-(#1/4096)*4096)+(#1-(#1/4096)*4096)/128\relax}% \fi\fi} \def\numbertoutf#1% raw characters are not active {\ifnum#1<\utf@g \rawcharacter{#1}% \else\ifnum#1<\utf@h \rawcharacter{\the\numexpr\utf@d+#1/\utf@a\relax}% \rawcharacter{\the\numexpr\utf@g+#1-(#1/\utf@a)*\utf@a\relax}% \else \rawcharacter{\the\numexpr\utf@e+#1/\utf@b\relax}% \rawcharacter{\the\numexpr\utf@g+(#1-(#1/\utf@b)*\utf@b)/\utf@g\relax}% \rawcharacter{\the\numexpr\utf@g+(#1-(#1/\utf@b)*\utf@b)+(#1-(#1/\utf@b)*\utf@b)/\utf@g\relax}% \fi\fi} \unprotect \def\v!xml{xml} \setupXMLprocessing [\c!escape=e] \def\XMLprocessingparameter#1% {\csname\??xp#1\endcsname} \appendtoks \defineXMLargument[\XMLprocessingparameter\c!escape]\getXMlentity \to \aftersetupXMLprocessing Hi, In the end i want more clever tuo/xml interaction, but for the moment i can provide: \bgroup \catcode`\<=\active \long\gdef\expandxmlargument#1\to {\begingroup \let\uppercase\firstofoneargument \def\getXMLhexcharacter##1{\numbertoutf{"##1}}% \def\getXMLdeccharacter##1{\numbertoutf{##1}}% \def\getXMLentity##1{<e>##1</e>} \def<{\noexpand<}% \xdef\@@globalexpanded{#1}% \endgroup \convertcommand\@@globalexpanded\to} \egroup \installexpander \v!xml {\expandxmlargument} \protect \setuphead[chapter][expansion=xml] \setuplist[chapter][textcommand=\enableXML] \enableregime[utf] \starttext \placelist[chapter] \defineXMLargument[chapter]{\chapter} \startXMLdata <chapter>test ë test &oeps; test <e>ediaresis</e></chapter> \stopXMLdata \stoptext I hope that i got the utf converter right Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hi Hans, I was preoccupied, so no time to respond before you had your own (incorrect) solution, sorry. Your conversion is not correct yet. Just a moment ... Taco
Here is the problem: \message{\the\numexpr 15/10 } % <- it rounds instead of truncates! your actual numbers were ok, afaik. Taco Hoekwater wrote:
Hi Hans,
I was preoccupied, so no time to respond before you had your own (incorrect) solution, sorry. Your conversion is not correct yet. Just a moment ...
Taco Hoekwater wrote:
Here is the problem:
\message{\the\numexpr 15/10 } % <- it rounds instead of truncates!
your actual numbers were ok, afaik.
so do i need to fix something (subtract 1 from #1 or so?) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Here you go (thanks to Nanning): \def\numbertoutf#1% {\ifnum#1<128 \rawcharacter{#1}% \else\ifnum#1<2048 \rawcharacter{\the\numexpr192+(#1-32)/64\relax}% \rawcharacter{\the\numexpr128 +(#1-((#1-32)/64)*64)\relax}% \else % 3 bytes \rawcharacter{\the\numexpr224 +(#1-2048)/4096\relax}% \rawcharacter{\the\numexpr128 +(#1-(((#1-2048)/4096)*4096)-32) /64\relax}% \rawcharacter{\the\numexpr128 +(#1-(((#1-2048)/4096)*4096) -((#1-(((#1-2048)/4096)*4096)-32) /64)*64)\relax}% \fi\fi} Hans Hagen wrote:
Taco Hoekwater wrote:
Here is the problem:
\message{\the\numexpr 15/10 } % <- it rounds instead of truncates!
your actual numbers were ok, afaik.
so do i need to fix something (subtract 1 from #1 or so?) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Taco Hoekwater