[Tex/LaTex] Unicode “undefined control sequence” in XeLaTeX

errorsunicodexetex

I have got a TeXLive 2011 on an Apple Time Machine and TeXShop on my local MacBook.
When I try to typeset the XeLaTeX template from TeXShop, I get “undefined control sequence” for some of the Unicode text.

The relevant section of the template goes as follows:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{scrartcl}
\usepackage{geometry}
\geometry{a4paper}

\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Hoefler Text}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Gill Sans}
\setmonofont[Scale=MatchLowercase]{Andale Mono}

\begin{document}

\newfontfamily{\A}{Geeza Pro}
\newfontfamily{\H}[Scale=0.9]{Lucida Grande}
\newfontfamily{\J}[Scale=0.85]{Osaka}

Here are some multilingual Unicode fonts: this is Arabic text: {\A السلام عليكم},
this is Hebrew: {\H שלום}, 
and here's some Japanese: {\J 今日は}.

\end{document}  

When I typeset this, I get:

./Untitled.tex:44: Undefined control sequence.
l.44 ...s: this is Arabic text: {\A \UTF
                                        {0627}\UTF{0644}\UTF{0633}\UTF{0644}...

Strangely, this occurs only for the Arabic and Hebrew texts, however, if I comment these out and leave only the Japanese section, the document is typeset without any errors and correct output.

At first, I thought that something was not passed correctly via the shell, but both bash and tcsh (used by TeXShop) return upon a locale:

LANG="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_CTYPE="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_ALL=

I even tried adding setenv LC_CTYPE en_US.UTF-8 (cf. this) to the XeLaTeX engine for TeXShop but that did not help, either.

This is the Log I get with the posted example.

I hope that you have any ideas concerning this problem.
Thank you in advance.

Best Answer

I would say your editor has exchanged the unicode chars by this \UTF-commands when saving the file. A search in the TeXshop forum came up with this advice: "Please UNCHECK TeXShop->Preferences->Misc->pTeX support-> utf export".