
\newwrite\mywrite
\immediate\openout\mywrite=\jobname.wrt
\immediate\write\mywrite{abc}
\immediate\closeout\mywrite

\newlength{\la}
\settowidth{\la}{\fbox{这是一个带测量宽度的盒子}}
\immediate\openout0=\jobname.txt
\immediate\write0{\the\la}
\immediate\closeout0
% \ShellEscape{set /p xxx=&&wscript "msgbox \%xxx\%"}
\immediate\write18{echo 222323}
% \read
\DeleteFile{\jobname.wrt}


% \newenvironment{myenv}  
% {\begin{quotation}\small\itshape}{\end{quotation}}  
  
% \newcommand{\replaced}[2][\relax]{\renewcommand{\tmpbox}{\fboxsep#1\colorbox{red}{\tmpbox}\par}\tmpbox}  
  
  
% \begin{myenv}  
% This is a test sentence.  
% \end{myenv}  
  
% \replaced[10pt]{\begin{myenv}  
% This is another test sentence.  
% \end{myenv}}  

% \newcommand{\code}[1]{\colorbox[RGB]{245,245,245}{\texttt{\detokenize{#1}}}}
% ...
% \code{std::string this_is_a_string = "\n";}
% \xpatchcmd{\regex_replace_all:NnN}{hello}{goodbye}{\typeout{Patched!}}{\typeout{Patching failed!}}
\ExplSyntaxOn


% \newenvironment{zhongwen}{
%     \newsavebox{\rawinput}
%     \begin{lrbox}{\rawinput}
% }{
%     \end{lrbox}
%     \immediate\write18{echo `\unhcopy\rawinput` > output.txt}
%     \newwrite\mywrite
%     \immediate\openout\mywrite=\jobname.wrt
%     \immediate\write\mywrite{\unhcopy\rawinput}
%     \regex_replace_all:nnN{a}{ifrfe}{\usebox{\rawinput}}
%     \unhcopy\rawinput
%     \unhcopy\rawinput
%     \unhcopy\rawinput
%     \immediate\write\mywrite{\unhcopy\rawinput}
%     \immediate\closeout\mywrite
% }

% \newenvironment{zhongwen}{
%     \regex_replace_all:nnN{at}{is}
%     \begingroup
% }{
%     % \egroup
%     \endgroup
% }

% https://www.jianshu.com/p/6dfd27b7bd90

\cs_new:Nn \my_add:nn {
    #1 + #2
}
\int_eval:n {
    \my_add:nn {123} {456}
} 
\str_new:N \temp
\cs_new:Nn \zhongwenfunction:n {
    \str_set:NV \temp {#1}
    \regex_replace_all:nnN{[^\x00-\xff]+}{\\text\{\0\}}{\temp}
    % \temp
    \immediate\openout0=\jobname.zhongwen
    \immediate\write0{\temp}
    \immediate\closeout0
    \input{\jobname.zhongwen}
    % \DeleteFile{\jobname.zhongwen}
    % \new
}
\NewEnviron{myenv}{\zhongwenfunction:n{\BODY}}
% \zhongwenfunction:n {
%     $$
%     a at is at is.
%     中文
%     中文2让中文
%     $$
% }
\begin{myenv}
    $$
    a at is at is.
    中文
    中文2让中文
    $$
\end{myenv}

\NewEnviron{zhongwen}{
    \ExplSyntaxOn
    \str_set:NV \temp {\BODY}
    \regex_replace_all:nnN{[^\x00-\xff]+}{\\text\{\0\}}{\temp}
    % 应该可以使用\ifwindows和\iflinux来判断临时文件目录从而把临时文件放到临时文件目录里的
    \immediate\openout0=\jobname.zhongwen
    \immediate\write0{\temp}
    \immediate\closeout0
    \input{\jobname.zhongwen}
    \DeleteFile{\jobname.zhongwen}
    \ExplSyntaxOff
}

\begin{zhongwen}
    $$
    中文中文
    飞机及哦额叫哦哦我i哦飞机饿哦i就发我哦佛偈哦哦哦挖机
    $$
\end{zhongwen}

\newcommand{\mycommand}[1]{\expandafter\def\csname myenv\endcsname{#1}}  
\mycommand{abc}
\verb|\begin{myenv}abc\end{myenv}|

\def\foo{hello}  
\def\bar{world}  
\def\baz{!}  

\foo\ \bar\ \baz

fefef

% \xdef\zhongwen{\regex_replace_all:nnN{at}{is}{\zhongwen}}

% \begin{zhongwen}
%     a at is at is.
% \end{zhongwen}

\def\openbox#1{\setbox#1=\hbox\bgroup}
\def\closebox#1{\egroup\usebox#1}
\openbox0 ... \closebox0

% \zhongwen {23232at is ao is at .}
% \xdef\mycommand{$2323$}
% \newsavebox{\mybox}

% \begin{lrbox}{\mybox}
%     fwojefjoiwejfio
% \end{lrbox}

% \usebox{\mybox}
% \usebox{\mybox}
% \usebox{\mybox}
% \usebox{\mybox}
% \usebox{\mybox}

% \mycommand


% \begin{zhongwen}  
%     This is some text inside the environment.  
% \end{zhongwen}  
      
% \xdef\myvariable{\begin{zhongwen}}  
% \expandafter\xdef\expandafter\myvariable\expandafter{\myvariable\end{zhongwen}}
      

\str_new:N \l_my_tl
\str_set:Nn \l_my_tl { That~cat. }
\l_my_tl
\regex_replace_all:nnN { at } { is } \l_my_tl
\l_my_tl

% \regex_replace_once:nnn { at } { is } {This is a sample text with some words.} 11515632
% \regex_replace_all:NnN
% \replace
% \regex_replace_all:nnn{\\b[a-z]+\\b}{X} This is a sample text with some words.
% {<->}
% {<*>}

换行

换行

换行
\ExplSyntaxOff

换行

换行

换行
