
   \ifnum\@tempcnta<`#2\relax
      \advance\@tempcnta\@ne
   \repeat}
+
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname XeTeXversion\endcsname\relax\else
+  \RequirePackage{xetex-inputenc}
+  \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{xetex-inputenc}}
+  \ProcessOptions*
+  \expandafter\endinput
+\fi
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname directlua\endcsname\relax\else
+  \RequirePackage{luainputenc}
+  \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{luainputenc}}
+  \ProcessOptions*
+  \expandafter\endinput
+\fi
+
 \ProcessOptions
 \endinput
 %%

