Skip to content

Commit d3c6df7

Browse files
GAPgap
authored andcommitted
Setting GAPInfo.TermEncoding to "ISO-8859-1" or "UTF-8" by examining
GAPInfo.SystemEnvironment. git-svn-id: path/gapdoc/trunk@141
1 parent 123a813 commit d3c6df7

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

init.g

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
##
33
#A init.g GAPDoc Frank Lübeck / Max Neunhöffer
44
##
5-
#H @(#)$Id: init.g,v 1.13 2007-03-05 16:51:11 gap Exp $
5+
#H @(#)$Id: init.g,v 1.14 2007-05-09 12:58:12 gap Exp $
66
##
77
#Y Copyright (C) 2000, Frank Lübeck and Max Neunhöffer,
88
#Y Lehrstuhl D für Mathematik, RWTH Aachen
@@ -25,3 +25,40 @@ ReadPackage("GAPDoc", "lib/Examples.gd");
2525
# The handler functions for GAP's help system are read now:
2626
ReadPackage("GAPDoc", "lib/HelpBookHandler.g");
2727

28+
# try to find terminal encoding
29+
GAPInfo.tmpfunc := function()
30+
local env, pos, enc, a;
31+
if not IsBound(GAPInfo.TermEncoding) then
32+
if IsList(GAPInfo.SystemEnvironment) then
33+
# for compatibility with GAP 4.4.
34+
env := rec();
35+
for a in GAPInfo.SystemEnvironment do
36+
pos := Position(a, '=');
37+
env.(a{[1..pos-1]}) := a{[pos+1..Length(a)]};
38+
od;
39+
else
40+
env := GAPInfo.SystemEnvironment;
41+
fi;
42+
enc := fail;
43+
if IsBound(env.LC_CTYPE) then
44+
enc := env.LC_CTYPE;
45+
fi;
46+
if enc = fail then
47+
enc := env.LC_ALL;
48+
fi;
49+
if enc = fail then
50+
enc := env.LANG;
51+
fi;
52+
if enc <> fail and
53+
(PositionSublist(enc, ".UTF-8") <> fail or
54+
PositionSublist(enc, ".utf8") <> fail) then
55+
GAPInfo.TermEncoding := "UTF-8";
56+
fi;
57+
if not IsBound(GAPInfo.TermEncoding) then
58+
# default is latin1
59+
GAPInfo.TermEncoding := "ISO-8859-1";
60+
fi;
61+
fi;
62+
end;
63+
GAPInfo.tmpfunc();
64+
Unbind(GAPInfo.tmpfunc);

0 commit comments

Comments
 (0)