# CJK and imakeidx - font encoding problems

I am using imakeidx to generate a list of persons appearing in a scientific book. The problem is that I want to mention all appearing authors in the own language which works fine in the document itself but is creating font encoding problems in the index.

Please find below a MWE where "角谷 静夫" works in the main text itself but not in the index.

\documentclass{scrbook}
\usepackage{CJKutf8}
\usepackage{textcomp}

\usepackage[utf8]{inputenc}
\usepackage[OT1, T2A]{fontenc}
\usepackage{imakeidx}

\makeindex[name=name, title = {List of Persons}]

\begin{document}
\begin{CJK}{UTF8}{min}角谷  静夫\end{CJK} (Shizuo Kakutani), \textborn{}~28th~August 1911 in Ōsaka \textdied{}~17th~August 2004 in New Haven, Connecticut, Japanese-American Mathematician
\index[name]{Kakutani@{\begin{CJK}{UTF8}{min}角谷 静夫\end{CJK}}}

\printindex[name]

\end{document}


The file name.idx contains many error messages of the following form:

Package inputenc Error: Unicode char 角 (U+89D2)\MessageBreak not set up for use with LaTeX


What can I do to make CJK work also in the index and not only in the main text itself?

You have to avoid untimely expanding \begin{CJK}:

\documentclass{scrbook}
\usepackage{CJKutf8}
\usepackage{textcomp}

\usepackage[utf8]{inputenc}
\usepackage[OT1, T2A]{fontenc}
\usepackage{imakeidx}

\newcommand{\nameindex}[2]{%
\index[name]{#1@\detokenize{\begin{CJK}{UTF8}{min}#2\end{CJK}}}%
}

\makeindex[name=name, title = {List of Persons}]

\begin{document}

\begin{CJK}{UTF8}{min}角谷  静夫\end{CJK} (Shizuo Kakutani)\nameindex{Kakutani}{角谷 静夫},
\textborn{}~28th~August 1911 in Ōsaka \textdied{}~17th~August 2004
in New Haven, Connecticut, Japanese-American Mathematician.

\printindex[name]

\end{document}