When the LaTeX format is built, there are tests for whether or not a
Unicode-aware TeX engine is doing the work. I presume that XeTeX is such a
Unicode-aware engine, though I'm not familiar with what the definition of
"Unicode-aware TeX engine" actually is (separate issue).
During the input of
the lccode tables are set by the macro layer not the engine code, it
reads in The Unicode consortium data file
tex/generic/unicode-data/UnicodeData.txt
and sets the lccode values and catcode values according to the data there.
see
tex/generic/unicode-data/load-unicode-data.tex
which is loaded a