For example, with this code
%! TEX program = lualatex
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\char_set_catcode_other:N %
\tl_set:Nn\var{%}
\tl_analysis_show:N\var
\ExplSyntaxOff
\end{document}
The output is
The token list \var contains the tokens:
> % (the character %).
as expected, and it also works with all the other special characters. However when I try it with the newline character (which is encoded with the byte with value 10 on UNIX)
\char_set_catcode_other:n {10}
\tl_set:Nn\var{
}
\tl_analysis_show:N\var
the output is
The token list \var is empty
Why is that happening? (also ^^J or ^^M results in the same output, while a literal newline results in the output below)
The token list \var contains the tokens:
> (the character ).
\<literal new line character>is not the same thing as\^^Jor\^^M. The latter is useful when e.g. you want to have the escape sequence for passing to\stringor\regex_replace_all:NNnto replace something with literal new line character. – user202729 Dec 28 '21 at 09:14