summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/oberdiek/listingsutf8.sty
blob: 894346ee89d9f86a7e600dab067b92ca1317d2dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
%%
%% This is file `listingsutf8.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% listingsutf8.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2007 by
%%    Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%% 
%% 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".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% This work consists of the main source file listingsutf8.dtx
%% and the derived files
%%    listingsutf8.sty, listingsutf8.pdf, listingsutf8.ins, listingsutf8.drv,
%%    listingsutf8-test1.tex, listingsutf8-test2.tex,
%%    listingsutf8-test3.tex, listingsutf8-test4.tex,
%%    listingsutf8-test5.tex.
%% 
\begingroup
  \catcode123 1 % {
  \catcode125 2 % }
  \def\x{\endgroup
    \expandafter\edef\csname lstU@AtEnd\endcsname{%
      \catcode35 \the\catcode35\relax
      \catcode64 \the\catcode64\relax
      \catcode123 \the\catcode123\relax
      \catcode125 \the\catcode125\relax
    }%
  }%
\x
\catcode35 6 % #
\catcode64 11 % @
\catcode123 1 % {
\catcode125 2 % }
\def\TMP@EnsureCode#1#2{%
  \edef\lstU@AtEnd{%
    \lstU@AtEnd
    \catcode#1 \the\catcode#1\relax
  }%
  \catcode#1 #2\relax
}
\TMP@EnsureCode{10}{12}% ^^J
\TMP@EnsureCode{33}{12}% !
\TMP@EnsureCode{36}{3}% $
\TMP@EnsureCode{38}{4}% &
\TMP@EnsureCode{39}{12}% '
\TMP@EnsureCode{40}{12}% (
\TMP@EnsureCode{41}{12}% )
\TMP@EnsureCode{42}{12}% *
\TMP@EnsureCode{43}{12}% +
\TMP@EnsureCode{44}{12}% ,
\TMP@EnsureCode{45}{12}% -
\TMP@EnsureCode{46}{12}% .
\TMP@EnsureCode{47}{12}% /
\TMP@EnsureCode{58}{12}% :
\TMP@EnsureCode{60}{12}% <
\TMP@EnsureCode{61}{12}% =
\TMP@EnsureCode{62}{12}% >
\TMP@EnsureCode{94}{7}% ^ (superscript)
\TMP@EnsureCode{95}{8}% _ (subscript)
\TMP@EnsureCode{96}{12}% `
\TMP@EnsureCode{124}{12}% |
\TMP@EnsureCode{126}{13}% ~ (active)
\g@addto@macro\lstU@AtEnd{\endinput}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{listingsutf8}%
  [2007/11/11 v1.1 Adding support for UTF-8 to listings (HO)]
\DeclareOption*{%
  \PassOptionsToPackage\CurrentOption{listings}%
}
\ProcessOptions*
\RequirePackage{listings}[2002/04/01]
\AtBeginDocument{%
  \@ifundefined{inputencoding}{%
    \RequirePackage{inputenc}%
  }{}%
}
\RequirePackage{pdftexcmds}[2007/11/11]
\def\lstU@temp#1#2{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname #1\endcsname\relax
    \PackageWarningNoLine{listingsutf8}{%
      Package loading is aborted because of missing %
      \@backslashchar#1.\MessageBreak
      #2%
    }%
    \expandafter\lstU@AtEnd
  \fi
}
\lstU@temp{scantokens}{It is provided by e-TeX}
\lstU@temp{pdf@unescapehex}{It is provided by pdfTeX >= 1.30}
\lstU@temp{pdf@filedump}{It is provided by pdfTeX >= 1.30}
\lstU@temp{pdf@filesize}{It is provided by pdfTeX >= 1.30}
\RequirePackage{stringenc}[2007/10/22]
\newif\iflstU@utfviii
\def\lstU@inputenc#1{%
  \expandafter\lstU@@inputenc#1utf8/utf8/\@nil
}
\def\lstU@@inputenc#1utf8/#2utf8/#3\@nil{%
  \ifx\\#1\\%
    \lstU@utfviiitrue
    \def\lst@inputenc{#2}%
  \else
    \lstU@utfviiifalse
  \fi
}
\lst@Key{inputencoding}\relax{%
  \def\lst@inputenc{#1}%
  \lstU@inputenc{#1}%
}
\def\lstU@input#1{%
  \iflstU@utfviii
    \edef\lstU@text{%
      \pdf@unescapehex{%
        \pdf@filedump{0}{\pdf@filesize{#1}}{#1}%
      }%
    }%
    \StringEncodingConvert\lstU@text\lstU@text{utf8}\lst@inputenc
    \def\lstU@temp{%
      \scantokens\expandafter{\lstU@text}%
    }%
  \else
    \def\lstU@temp{%
      \input{#1}%
    }%
  \fi
  \lstU@temp
}
\def\lstU@temp#1\def\lst@next#2#3\@nil{%
  \def\lst@InputListing##1{%
    #1%
    \def\lst@next{\lstU@input{##1}}%
    #3%
  }%
}
\expandafter\lstU@temp\lst@InputListing{#1}\@nil
\lstU@AtEnd
\endinput
%%
%% End of file `listingsutf8.sty'.