# Is this the best way to put unicode in a non-UTF-8 source?

I want to put the following phrase into a book.

``````Khabarovsk (Russian: Хабаровск)
is located 30 kilometers (19 mi)
from the Chinese border.
``````

The source is NOT UTF-8 and I don't have the option to make it UTF-8. I want to enter the Russian characters in a robust way that will not be distorted when the file is transferred between different people, and so I am limited to ASCII.

I have entered this:

``````Khabarovsk (Russian: \char"0425 \char"0430 \char"0431 \char"0430
\char"0440 \char"043E \char"0432 \char"0441 \char"043A )
is located 30 kilometers (19 mi)
from the Chinese border.
``````

This works in XeLaTeX (which is what I am using). Is this really the best way to enter these Unicode character code-points into LaTeX source?

Is there a standard way to specify a Unicode character that will work across all versions of LaTeX? If not, any comments on why there is no such standard notation for this? I am just trying to understand where all this is going.

CONCLUSION:

Let me expand upon the excellent answer given by David Carlisle below. The caret notation would be like this:

``````Khabarovsk (Russian:
^^^^0425^^^^0430^^^^0431^^^^0430^^^^0440^^^^043e^^^^0432^^^^0441^^^^043a)
is located 30 kilometers (19 mi)
from the Chinese border.
``````

This is superior for a number of reasons:

1. The \char form 'eats' a space after the command (the way TeX normally does) and that means that if you want a space, you have to do something special, like put an extra slash-space (standard TeX command behavior). The caret notation is exactly like a character: put a space between them and that space works like a space between characters.
2. This conversion is done at the initial parsing level, which means these characters can be used for anything in TeX, including spelling of commands. They simply represent characters in the input stream for any purpose.
3. David implied that the \char notation might be picking a code point in a font. I suppose most fonts use Unicode so this might or might not be a problem, but in any case using the caret notation allows the character to be processed by all the following logic exactly as if you typed the character into the source file.
4. The notation is slightly more compact: 8 characters instead of 10.

Only note: the hex digits MUST use lower case letters. I don't know for sure, but I assume this only works on XeTeX and variants of that.

See further discussion at blog post on Adding Unicode Characters to LaTeX documents

It's probably better to use `^^^^043a` which produces a character token, rather than use `\char"043A` which is a non expandable primitive accessing a font position. The character token is usable in more contexts (such as writing to tables of contents) and generally has less restrictions than `\char`.
the `^^^^` notation (and `\char"043A`) will work in luatex or xetex, neither work in pdftex which can not access slots above `"FF` To use unicode naturally in pdftex you really want to use utf8 encoding and `inputenc`.
• @AgilePro Four `^` want four hexadecimal digits (with `a-f` lowercase); five want five and six want six. Apr 6, 2015 at 8:45
• Even in PDFTeX you can still `^^` individual UTF8 byte and `\usepackage[utf8]{inputenc}`. ____________________________________________________________________________________________ The double-^ notation is documented in the TeXBook (chapter 8: The Characters You Type, page 47. Oct 23, 2021 at 2:31
• The extended syntax is documented in LuaTeX manual: "The `^^` notation has been extended: after `^^^^` four hexadecimal characters are expected and after `^^^^^^` six hexadecimal characters have to be given." ■ @egreg Note that five `^` doesn't work in LuaTeX. ■ It's also in the XeTeX companion: "extension of TEX primitives" → "four-digit notation using the syntax `^^^^abcd`", although oddly enough it explicitly say that characters not in BMP aren't supported, although it's supported well (despite some minor bugs). Oct 23, 2021 at 2:44
• @user202729 beware commenting on old answers, xetex and luatex normalised their `^^^^` usage a while ago, 5 `^` used to be supported, the xetex manual was also probably correct when it was written and missed an update when `^^^^^^` support added. aslo for pdflatex you don't need `\usepackage[utf8]{inputenc}` UTF-8 is the default (although it wasn't when this answer was written) Oct 23, 2021 at 3:18