% cjkutf8-nanummjhanja.sty
%
% Copyright (c) 2016 Dohyun Kim <nomos at ktug org>
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program in doc/COPYING; if not, write to the Free
% Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
% MA 02110-1301 USA

\ProvidesPackage{cjkutf8-nanummjhanja}
  [2016/04/04 v1.8 UHC hanja for Nanum Myeongjo]

\def\CJKKO@mjdefault{nanummj}
\def\CJKKO@mjhanjafamily{\def\CJK@family{uhcmj}}

% redefine CJK@numbToHex
\def\CJK@numbToHex#1#2{%
  {\count\z@ #2\relax
   \count\tw@ \count\z@
   \divide\count\z@ \sixt@@n
   \count@ \count\z@
   \multiply\count@ \sixt@@n
   \advance\count\tw@ -\count@
   \xdef#1{%
     \hexnumber@{\count\z@}\hexnumber@{\count\tw@}}}%
  % inserted
  \ifx\CJK@family\CJKKO@mjdefault
    \expandafter\CJKKO@checkhanjaplane#1\fi}

\def\CJKKO@checkhanjaplane#1#2{%
  \begingroup
  \count@\ifx#1A10\else
         \ifx#1B11\else
         \ifx#1C12\else
         \ifx#1D13\else
         \ifx#1E14\else
         \ifx#1F15\else
         #1\fi\fi\fi\fi\fi\fi
  \@tempcnta\ifx#2A10\else
            \ifx#2B11\else
            \ifx#2C12\else
            \ifx#2D13\else
            \ifx#2E14\else
            \ifx#2F15\else
            #2\fi\fi\fi\fi\fi\fi
  \multiply\count@\sixt@@n \advance\count@\@tempcnta
  \ifnum\count@>"4D \ifnum\count@<"A0 \aftergroup\CJKKO@mjhanjafamily \else
  \ifnum\count@>"F8 \ifnum\count@<"FB \aftergroup\CJKKO@mjhanjafamily
  \fi\fi\fi\fi
  \endgroup }

\endinput
