%% %% This is file `xCJK2uni.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% xCJK2uni.dtx (with options: `package') %% %% Copyright (C) 2013-2014, 2016, 2018-2020 by Qing Lee %% -------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either %% version 1.3c of this license or (at your option) any later %% version. This version of this license is in %% http://www.latex-project.org/lppl/lppl-1-3c.txt %% and the latest version of this license is in %% http://www.latex-project.org/lppl.txt %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% %% This work has the LPPL maintenance status "maintained". %% %% The Current Maintainer of this work is Qing Lee. %% %% -------------------------------------------------------------------------- %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} \GetIdInfo$Id: xCJK2uni.dtx daef005 2020-05-01 21:09:45 +0800 Qing Lee $ {Convert CJK character to Unicode.} \ProvidesExplPackage{\ExplFileName} {\ExplFileDate}{1.0}{\ExplFileDescription} \msg_new:nnn { xCJK2uni } { l3-too-old } { Support~package~'expl3'~too~old. \\\\ Please~update~an~up~to~date~version~of~the~bundles\\\\ 'l3kernel'~and~'l3packages'\\\\ using~your~TeX~package~manager~or~from~CTAN. } \@ifpackagelater { expl3 } { 2020/03/06 } { } { \msg_error:nn { xCJK2uni } { l3-too-old } } \sys_if_engine_pdftex:F { \msg_new:nnn { xCJK2uni } { pdflatex } { The~xCJK2uni~package~is~only~supported~in~pdfTeX. } \msg_critical:nn { xCJK2uni } { pdflatex } } \tl_new:N \l__CJKtu_sfd_tl \prop_new:N \c__CJKtu_sfd_prop \seq_new:N \c__CJKtu_encoding_seq \int_new:N \l__CJKtu_i_min_int \int_new:N \l__CJKtu_i_max_int \int_new:N \l__CJKtu_ii_min_int \int_new:N \l__CJKtu_ii_max_int \int_new:N \l__CJKtu_gap_begin_int \int_new:N \l__CJKtu_gap_end_int \int_new:N \l__CJKtu_plane_int \int_set:Nn \l__CJKtu_i_max_int { "FE } \int_set:Nn \l__CJKtu_ii_max_int { "FE } \cs_new_protected:Npn \__CJKtu_set_enc:nnnnnn #1#2#3#4#5#6 { \seq_gput_right:Nn \c__CJKtu_encoding_seq {#1} \prop_gput:Nnn \c__CJKtu_sfd_prop {#1} {#2} \int_const:cn { c__CJKtu_ #1 _i_min_int } {#3} \int_const:cn { c__CJKtu_ #1 _ii_min_int } {#4} \tl_if_empty:nTF {#5} { \int_const:cn { c__CJKtu_ #1 _gap_begin_int } { \l__CJKtu_ii_max_int + 1 } \int_const:cn { c__CJKtu_ #1 _gap_end_int } { \use:c { c__CJKtu_ #1 _gap_begin_int } } \int_const:cn { c__CJKtu_ #1 _plane_int } { \l__CJKtu_ii_max_int - (#4) + 1 } } { \int_const:cn { c__CJKtu_ #1 _gap_begin_int } { #5 + 1 } \int_const:cn { c__CJKtu_ #1 _gap_end_int } {#6} \int_const:cn { c__CJKtu_ #1 _plane_int } { (#5) - (#4) + \l__CJKtu_ii_max_int - (#6) + 2 } } \cs_if_exist_use:NTF \CJKaddEncHook { {#1} { \__CJKtu_enc_map:nn {#1} {#2} } } { \AtBeginDocument { \cs_if_exist_use:NT \CJKaddEncHook { {#1} { \__CJKtu_enc_map:nn {#1} {#2} } } } } } \cs_new_protected:Npn \__CJKtu_enc_map:nn #1#2 { \int_set_eq:Nc \l__CJKtu_i_min_int { c__CJKtu_ #1 _i_min_int } \int_set_eq:Nc \l__CJKtu_ii_min_int { c__CJKtu_ #1 _ii_min_int } \int_set_eq:Nc \l__CJKtu_gap_begin_int { c__CJKtu_ #1 _gap_begin_int } \int_set_eq:Nc \l__CJKtu_gap_end_int { c__CJKtu_ #1 _gap_end_int } \int_set_eq:Nc \l__CJKtu_plane_int { c__CJKtu_ #1 _plane_int } \cs_if_exist:cF { CJKtu_ #1 _index_map:n } { \__CJKtu_input_sfd_map:n {#2} } \cs_set_eq:Nc \__CJKtu_index_map:n { CJKtu_ #1 _index_map:n } } \cs_new_protected:Npn \__CJKtu_input_sfd_map:n #1 { \group_begin: \ExplSyntaxOn \file_input:n { xCJK2uni-#1.def } \group_end: } \cs_new:Npn \CJKtu_index_map:n #1 { \CJKtu_unicode:n { \__CJKtu_index_map:n {#1} } } \cs_new_eq:NN \CJKtu_unicode:n \use:n \cs_new_eq:NN \__CJKtu_index_map:n \use_none:n \cs_new_protected:Npn \CJKtu_index_map:nn #1 { \exp_args:Ncc \__CJKtu_index_map_aux:NNn { CJKtu_ #1 _index_map:n } { c__CJKtu_ #1 _intarray } } \cs_new_protected:Npn \__CJKtu_index_map_aux:NNn #1#2 { \cs_new:Npn #1 ##1 { \intarray_item:Nn #2 { ##1 + 1 } } \intarray_const_from_clist:Nn #2 } \cs_new:Npn \CJKtu_sfd_map:nn #1#2 { \CJKtu_index_map:n { ( #1 - 1 ) * 256 + (#2) } } \cs_new_protected:Npn \CJKtu_use_enc_map:n #1 { \prop_get:NnNTF \c__CJKtu_sfd_prop {#1} \l__CJKtu_sfd_tl { \__CJKtu_enc_map:nn {#1} { \l__CJKtu_sfd_tl } } { \msg_error:nnx { xCJK2uni } { invalid-encoding } {#1} } } \msg_new:nnn { xCJK2uni } { invalid-encoding } { The~enconding~`#1'~is~invalid.\\ Only~\seq_use:Nnnn \c__CJKtu_encoding_seq { ~and~ } { ,~ } { ,~and~ } ~ are~supported. } \cs_generate_variant:Nn \CJKtu_use_enc_map:n { x } \__CJKtu_set_enc:nnnnnn { GB } { UGB } { "A1 } { "A1 } { } { } \__CJKtu_set_enc:nnnnnn { JIS } { UJIS } { "A1 } { "A1 } { } { } \__CJKtu_set_enc:nnnnnn { KS } { UKS } { "A1 } { "A1 } { } { } \__CJKtu_set_enc:nnnnnn { Bg5 } { UBig5 } { "A1 } { "40 } { "7E } { "A1 } \__CJKtu_set_enc:nnnnnn { Bg5+ } { UBg5plus } { "81 } { "40 } { "7E } { "80 } \__CJKtu_set_enc:nnnnnn { GBK } { UGBK } { "81 } { "40 } { "7E } { "80 } \group_begin: \char_set_catcode_active:n { "7F } \cs_new:Npn \CJKtu_char_to_unicode:n #1 { \int_compare:nNnTF { \tl_count:n {#1} } = 2 { \CJKtu_byte:NN #1 } { \tl_if_head_eq_meaning:nNTF {#1} ^^7f { \__CJKtu_byte:wNwnw #1 } { \__CJKtu_encoding_error: } } } \cs_new:Npn \__CJKtu_byte:wNwnw ^^7f #1 ^^7f #2 ^^7f { \CJKtu_byte_map:nn { `#1 } {#2} } \cs_new:Npn \__CJKtu_active_byte:Nwnw #1 ^^7f #2 ^^7f { \CJKtu_byte_map:nn { `#1 } {#2} } \cs_new_protected:Npn \CJKtu_bookmarks_hook: { \cs_set_eq:NN ^^7f \__CJKtu_active_byte:Nwnw \cs_set_eq:NN \CJK@XX \CJKtu_byte:NN \cs_set_eq:NN \CJKchar \__CJKtu_byte:wnn \cs_set_eq:NN \CCTchar \CJKtu_byte:nn \cs_set_eq:NN \@CCTSetChar \__CJKtu_CCT_byte:NNN \cs_set_eq:NN \CJKtu_unicode:n \__CJKtu_UTF_xvi_be_octal:n } \group_end: \cs_new:Npn \CJKtu_byte:NN #1#2 { \CJKtu_byte:nn { `#1 } { `#2 } } \cs_new:Npn \__CJKtu_CCT_byte:NNN #1#2#3 { \CJKtu_byte:nn { `#1 } { `#3 } } \cs_new:Npn \__CJKtu_byte:wnn #1# { \CJKtu_byte:nn } \cs_new:Npn \CJKtu_byte:nn #1#2 { \int_compare:nTF { \l__CJKtu_i_min_int <= #1 <= \l__CJKtu_i_max_int } { \int_compare:nTF { \l__CJKtu_ii_min_int <= #2 < \l__CJKtu_gap_begin_int } { \CJKtu_byte_map:nn {#1} {#2} } { \int_compare:nTF { \l__CJKtu_gap_end_int <= #2 <= \l__CJKtu_ii_max_int } { \CJKtu_byte_map:nn {#1} {#2} } { \__CJKtu_encoding_error: } } } { \__CJKtu_encoding_error: } } \cs_new:Npn \__CJKtu_encoding_error: { \msg_expandable_error:nn { xCJK2uni } { encoding-error } } \msg_new:nnn { xCJK2uni } { encoding-error } { Wrong~encoding~scheme. } \cs_new:Npn \CJKtu_byte_map:nn #1#2 { \exp_args:Nf \CJKtu_index_map:n { \int_eval:n { ( #1 - \l__CJKtu_i_min_int ) * \l__CJKtu_plane_int + (#2) - \l__CJKtu_ii_min_int \int_compare:nNnF {#2} < \l__CJKtu_gap_begin_int { + \l__CJKtu_gap_begin_int - \l__CJKtu_gap_end_int } } } } \cs_new:Npn \__CJKtu_UTF_xvi_be_octal:n #1 { \exp_args:Nf \__CJKtu_UTF_xvi_be_octal_aux:n { \int_eval:n {#1} } } \cs_new:Npn \__CJKtu_UTF_xvi_be_octal_aux:n #1 { \__CJKtu_UTF_xvi_be_octal:nn { \int_div_truncate:nn {#1} { 256 } } { \int_mod:nn {#1} { 256 } } } \cs_new:Npn \__CJKtu_UTF_xvi_be_octal:nn #1#2 { \HyPsd@DecimalToOctalFirst {#1} \HyPsd@DecimalToOctalSecond {#2} } \cs_if_exist_use:NTF \hypersetup { { unicode , CJKbookmarks = false } } { \PassOptionsToPackage { unicode , CJKbookmarks = false } { hyperref } } \msg_new:nnn { xCJK2uni } { UTF-8-encoding } { It~is~not~necessary~to~load~xCJK2uni~in~UTF-8~encoding. } \tl_if_exist:NF \pdfstringdefPreHook { \tl_new:N \pdfstringdefPreHook } \@ifpackageloaded { CJKutf8 } { \msg_warning:nn { xCJK2uni } { UTF-8-encoding } } { \cs_new_eq:NN \CJKtu@bookmarks@hook \CJKtu_bookmarks_hook: \tl_gput_right:Nn \pdfstringdefPreHook { \CJKtu@bookmarks@hook } \AtBeginDocument { \@ifpackageloaded { CJKutf8 } { \cs_gset_eq:NN \CJKtu@bookmarks@hook \scan_stop: \msg_warning:nn { xCJK2uni } { UTF-8-encoding } } { \cs_if_exist_use:NT \hypersetup { { CJKbookmarks = false } } } } } \cs_new_eq:NN \useCJKencmap \CJKtu_use_enc_map:x \cs_new_eq:NN \CJKchartouni \CJKtu_char_to_unicode:n \cs_new_eq:NN \CJKsfdtouni \CJKtu_sfd_map:nn \cs_new_protected:Npn \__CJKtu_initial:N #1 { \tl_if_exist:NTF #1 { \prop_get:NxNTF \c__CJKtu_sfd_prop {#1} \l__CJKtu_sfd_tl { \__CJKtu_enc_map:nn {#1} { \l__CJKtu_sfd_tl } } { \CJKtu_use_enc_map:n { GBK } } } { \CJKtu_use_enc_map:n { GBK } } } \prg_generate_conditional_variant:Nnn \prop_get:NnN { Nx } { TF } \group_begin: \exp_args:NNc \group_end: \__CJKtu_initial:N { CJK @ @ @ enc } %% %% This package consists of the file xCJK2uni.dtx, %% and the derived files xCJK2uni.pdf, %% xCJK2uni.sty, %% xCJK2uni.ins, %% xCJK2uni-make.tex, %% xCJK2uni-sfd.def, %% xCJK2uni-UBg5plus.def, %% xCJK2uni-UBig5.def, %% xCJK2uni-UGB.def, %% xCJK2uni-UGBK.def, %% xCJK2uni-UJIS.def, %% xCJK2uni-UKS.def, %% c****.cmap, and %% README.md. %% %% End of file `xCJK2uni.sty'.