From fe5a4c8c81ef2e5dca844732c7f24545b5edaca9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Sat, 7 Jul 2012 13:37:26 +0200 Subject: [PATCH] tex2lyx: improve CJK handling - tex2lyx/text.cpp: - fix bug that swallowed valid braces - the encoding is "Bg5" not "BIG5" - add and update comments - CJK.tex: add an example for the Bg5 encoding --- src/tex2lyx/test/CJK.tex | 4 ++++ src/tex2lyx/text.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/tex2lyx/test/CJK.tex b/src/tex2lyx/test/CJK.tex index 49ee35fa56..b469b895d7 100644 --- a/src/tex2lyx/test/CJK.tex +++ b/src/tex2lyx/test/CJK.tex @@ -18,6 +18,10 @@ hello Chinese simplified \end{CJK}\begin{CJK}{EUC-JP}{hei} Japanese \end{CJK} \begin{CJK}{GB}{}Chinese simplified \end{CJK} +\begin{CJK}{Bg5}{} +Big5 文鼎楷書 +\end{CJK} + \inputencoding{latin9}% \selectlanguage{english}% English diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 0d1a3d00e5..62d5e8df9e 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -119,6 +119,9 @@ char const * const known_coded_ref_commands[] = { "ref", "pageref", "vref", /** * supported CJK encodings + * SJIS anf Bg5 cannot be supported as this is not + * supported by iconv + * JIS does not work with LyX's encoding conversion */ const char * const supported_CJK_encodings[] = { "EUC-JP", "KS", "GB", "UTF8", 0}; @@ -1428,9 +1431,9 @@ void parse_environment(Parser & p, ostream & os, bool outer, // store the encoding to be able to reset it string const encoding_old = p.getEncoding(); string const encoding = p.getArg('{', '}'); - // SJIS and BIG5 don't work with LaTeX according to the comment in unicode.cpp + // SJIS and Bg5 cammopt be handled by iconv // JIS does not work with LyX's encoding conversion - if (encoding != "SJIS" && encoding != "BIG5" && encoding != "JIS") + if (encoding != "Bg5" && encoding != "JIS" && encoding != "SJIS") p.setEncoding(encoding); else p.setEncoding("utf8"); @@ -1442,7 +1445,7 @@ void parse_environment(Parser & p, ostream & os, bool outer, parent_context.check_layout(os); handle_ert(os, "\\begin{" + name + "}{" + encoding + "}{" + mapping + "}", parent_context); - // we must parse the content as verbatim because e.g. SJIS can contain + // we must parse the content as verbatim because e.g. JIS can contain // normally invalid characters string const s = p.plainEnvironment("CJK"); for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) { @@ -1453,7 +1456,6 @@ void parse_environment(Parser & p, ostream & os, bool outer, else os << *it; } - p.skip_spaces(); handle_ert(os, "\\end{" + name + "}", parent_context); } else { -- 2.39.2