<div dir="ltr"><div><div><div><div><div><br></div>Would it be possible (ever:-) to add a \Uchar primitive like that in luatex?<br></div><br>So like \char but is expandable and returns a character token rather than a typesetting primitive.<br>
<br></div>This would be useful in lots of situations, in particular for lowercase constructs and encoding mapping. In classic TeX it's feasible to do these things with explicit lists cf \alph and \Alph in LaTeX are expandable as they don't use \uppercase or \lowercase but each have an explicit list of "all" the letters, but there are rather a lot of Unicode letters, so that isn't feasible in extended texs:-).  Similar issues come up while trying to handle different encodings.<br>
<br></div>An enhanced version that also allowed you to control the catcode of the generated character would be nice, especially if luatex added it at the same time, but a basic \Uchar to match that in luatex would already be very useful and make it much easier to write portable code across the two engines (or in fact to support expandable character mapping constructs in xetex at all).<br>
<br></div><div>You can almost fake \UChar"221E   with \scantokens{^^^^221e} but that requires \everyeof to be set with a trick \noexpand to hide the end of file, and requires ^ to have catcode 7, and you can't set those in an expandable way, apart from the fact that scanning a fake internal file seems a heavyweight solution to generate a single character token.<br>
</div><div><br></div>David<br><div><div><br><br></div></div></div>