How to adapt tcolorbox with XeLaTex

The style=tcblatex loads inputenc automatically.

Remove this key when used with xelatex or lualatex.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[most]{tcolorbox}

\newtcblisting{cisco}[1][]{size=fbox, listing only, listing options={basicstyle=\ttfamily\scriptsize,tabsize=2,language=sh},#1}

\begin{document}

\begin{cisco}[title=Example of cisco command]
master#show ip cef 10.200.254.4
10.200.254.4/32, version 44, epoch 0, cached adjacency 10.200.200.2
0 packets, 0 bytes
    tag information set, all rewrites owned
    local tag: 20
    fast tag rewrite with Eth0/0/0, 10.200.200.2, tag imposed {18} via 10.200.200.2, Ethernet0/0/0, 0 dependencies
    next hop 10.200.200.2, Ethernet0/0/0
    valid cached adjacency
    tag rewrite with Et0/0/0, 10.200.200.2, tags imposed {18}
\end{cisco}

\end{document}

You have to pass the inputencoding=utf8 among the options of newtcblisting. This will pass the option to the inputenc package internally which is then redundant for the Xe/Lua LaTeX engines (you get a warning, about it not being necessary, that's it):

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[most]{tcolorbox}

\newtcblisting{cisco}[1][]{size=fbox, listing only, listing options={style=tcblatex,basicstyle=\ttfamily\scriptsize,tabsize=2,language=sh,inputencoding=utf8},#1}

\begin{document}

\begin{cisco}[title=Example of cisco command]
master#show ip cef 10.200.254.4
10.200.254.4/32, version 44, epoch 0, cached adjacency 10.200.200.2
0 packets, 0 bytes
    tag information set, all rewrites owned
    local tag: 20
    fast tag rewrite with Eth0/0/0, 10.200.200.2, tag imposed {18} via 10.200.200.2, Ethernet0/0/0, 0 dependencies
    next hop 10.200.200.2, Ethernet0/0/0
    valid cached adjacency
    tag rewrite with Et0/0/0, 10.200.200.2, tags imposed {18}
\end{cisco}

\end{document}

giving:

enter image description here


You can fool the package tcolorbox that inputenc is already loaded:

\documentclass{article}
\makeatletter\@namedef{[email protected]}{}\makeatother
\usepackage{fontspec}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage[most]{tcolorbox}

\newtcblisting{cisco}[1][]{size=fbox, listing only, listing 
options={style=tcblatex,basicstyle=\ttfamily\scriptsize,tabsize=2,language=sh},#1}

\begin{document}

\begin{cisco}[title=Example of cisco command]
  master#show ip cef 10.200.254.4
  10.200.254.4/32, version 44, epoch 0, cached adjacency 10.200.200.2
  0 packets, 0 bytes
  tag information set, all rewrites owned
  local tag: 20
  fast tag rewrite with Eth0/0/0, 10.200.200.2, tag imposed {18} via 10.200.200.2, 
  Ethernet0/0/0, 0 dependencies
  next hop 10.200.200.2, Ethernet0/0/0
  valid cached adjacency
  tag rewrite with Et0/0/0, 10.200.200.2, tags imposed {18}
\end{cisco}

\end{document}

enter image description here