add pure ASCII encoding for LaTeX export

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17224 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2007-02-16 18:29:48 +00:00
parent e04b3303a1
commit 6bf6c8453d
8 changed files with 32 additions and 5 deletions

View File

@ -1,6 +1,10 @@
LyX file-format changes
-----------------------§
2007-02-16 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* format incremented to 260: Allow ascii \inputencoding
2007-02-14 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* format incremented to 261: \output_changes is now considered

View File

@ -114,3 +114,7 @@ End
Encoding pt254 pt254 PT254
End
# Pure 7bit ASCII encoding (partially hardcoded in LyX)
Encoding ascii ascii ascii
End

View File

@ -74,7 +74,7 @@ format_relation = [("0_06", [200], generate_minor_versions("0.6" , 4)),
("1_2", [220], generate_minor_versions("1.2" , 4)),
("1_3", [221], generate_minor_versions("1.3" , 7)),
("1_4", range(222,246), generate_minor_versions("1.4" , 3)),
("1_5", range(246,262), generate_minor_versions("1.5" , 0))]
("1_5", range(246,263), generate_minor_versions("1.5" , 0))]
def formats_list():

View File

@ -1210,6 +1210,18 @@ def convert_changes(document):
document.header[j] = "\\output_changes false"
def revert_ascii(document):
" Set ascii encoding to auto. "
i = find_token(document.header, "\\inputencoding", 0)
if i == -1:
document.header.append("\\inputencoding auto")
else:
inputenc = get_value(document.header, "\\inputencoding", i)
if inputenc == "ascii":
document.header[i] = "\\inputencoding auto"
document.inputencoding = get_value(document.header, "\\inputencoding", 0)
##
# Conversion hub
#
@ -1230,9 +1242,11 @@ convert = [[246, []],
[258, [convert_lyxline]],
[259, [convert_accent, normalize_font_whitespace]],
[260, []],
[261, [convert_changes]]]
[261, [convert_changes]],
[262, []]]
revert = [[260, []],
revert = [[261, [revert_ascii]],
[260, []],
[259, [revert_utf8x]],
[258, []],
[257, []],

View File

@ -141,7 +141,7 @@ using std::string;
namespace {
int const LYX_FORMAT = 261;
int const LYX_FORMAT = 262;
} // namespace anon

View File

@ -876,7 +876,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
os << "]{inputenc}\n";
texrow.newline();
}
} else if (inputenc != "default" && inputenc != "tis620-0") {
} else if (inputenc != "default" && inputenc != "tis620-0" &&
inputenc != "ascii") {
os << "\\usepackage[" << from_ascii(inputenc)
<< "]{inputenc}\n";
texrow.newline();

View File

@ -211,6 +211,9 @@ CharInfoMap unicodesymbols;
Encoding::Encoding(string const & n, string const & l, string const & i)
: Name_(n), LatexName_(l), iconvName_(i)
{
if (n == "ascii")
// ASCII can encode 128 code points and nothing else
start_encodable_ = 128;
if (n == "utf8" || n == "utf8x")
// UTF8 can encode all 1<<20 + 1<<16 UCS4 code points
start_encodable_ = 0x110000;

View File

@ -592,6 +592,7 @@ int switchEncoding(odocstream & os, BufferParams const & bparams,
// only, but it is the best we can do.
if ((bparams.inputenc == "auto" || bparams.inputenc == "default") &&
oldEnc.name() != newEnc.name() &&
oldEnc.name() != "ascii" && newEnc.name() != "ascii" &&
oldEnc.name() != "tis620-0" && newEnc.name() != "tis620-0") {
lyxerr[Debug::LATEX] << "Changing LaTeX encoding from "
<< oldEnc.name() << " to "