1

I use the following expl3 code to upper-case the first character of a programmatic string. The code is from the body of a control sequence definition and is not supposed to be fully expandable.

\tl_set:Nn
  \l_tmpa_tl
  { \str_uppercase:n { #1 } }

\tl_set:Nx \l_tmpb_tl { \tl_head:f { \l_tmpa_tl } \tl_tail:n { #1 } }

However, I need my code to work with TeX Live 2019 and the \str_uppercase:n control sequence is unavailable in TeX Live 2019. Since I know that #1 will only contain ASCII letters, I assumed that I would be able to substitute \str_uppercase:n with \uppercase. However, \uppercase seems to defy expansion, so \tl_head:f { \l_tmpa_tl } will produce the \uppercase token rather than the first uppercase character.

Witiko
  • 1,216
  • the uppercasing code has been available for longer than that, possibly originally in package form, Joseph can answer the deails:-) – David Carlisle Mar 05 '22 at 14:07
  • That would be useful, although I should mention that this is plain TeX code, i.e. expl3-generic.tex, not LaTeX. Therefore, LaTeX packages are unavailable. – Witiko Mar 05 '22 at 16:09

1 Answers1

1

However, \uppercase seems to defy expansion, so \tl_head:f { \l_tmpa_tl } will produce the \uppercase token rather than the first uppercase character.

That is because the \uppercase primitive is unexpandable and processed by the execution processor rather than the expansion processor, see also \expandafter with \uppercase.

I need my code to work with TeX Live 2019 and the \str_uppercase:n control sequence is unavailable in TeX Live 2019.

According to the LaTeX 3 newsletter from November 2016, the \str_upper_case:n command has been available since TeX Live 2017. In 2020, it has been renamed to \str_uppercase:n and deprecated. However, the deprecated command \str_upper_case:n is still available.

Witiko
  • 1,216