summaryrefslogtreecommitdiffstats
path: root/src/util.cpp
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2018-07-23 16:47:56 (GMT)
committeralbert-github <albert.tests@gmail.com>2018-07-23 16:47:56 (GMT)
commit0f8902275a4c02196d4eb1398e621a349355410a (patch)
tree760015456f1166f992f7205921109465bdfd8bd1 /src/util.cpp
parent198abce439d91d9d877570ec335bfd26a31d8526 (diff)
downloadDoxygen-0f8902275a4c02196d4eb1398e621a349355410a.zip
Doxygen-0f8902275a4c02196d4eb1398e621a349355410a.tar.gz
Doxygen-0f8902275a4c02196d4eb1398e621a349355410a.tar.bz2
Improvements in handling special characters in Latex
- In case a corrupted character is found LaTeX shows this as a U+FFFD , the character in the code is 0xef 0xbf oxbd. This character was in the LaTex Code already replaced with `\ucr` but this didn't work properly with TexLive 2015 and the code is now detected i the doxygen code and directly replaced `\ucr` - other special characters are now handled, in a way that works in all engines, by means of `\newunicodechar` - the size of the `\ucr` was not set in case it was used in 'running text' and not inside e.g. a code section.
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/util.cpp b/src/util.cpp
index a0522d4..6c7e3d5 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -6741,6 +6741,16 @@ void filterLatexString(FTextStream &t,const char *str,
{
switch(c)
{
+ case 0xef: // handle U+FFFD i.e. "Replacement character" caused by octal: 357 277 275 / hexadecimal 0xef 0xbf 0xbd
+ // the LaTeX command \ucr has been defined in doxygen.sty
+ if ((unsigned char)*(p) == 0xbf && (unsigned char)*(p+1) == 0xbd)
+ {
+ t << "{\\ucr}";
+ p += 2;
+ }
+ else
+ t << (char)c;
+ break;
case '\\': t << "\\(\\backslash\\)"; break;
case '{': t << "\\{"; break;
case '}': t << "\\}"; break;
@@ -6762,6 +6772,16 @@ void filterLatexString(FTextStream &t,const char *str,
{
switch(c)
{
+ case 0xef: // handle U+FFFD i.e. "Replacement character" caused by octal: 357 277 275 / hexadecimal 0xef 0xbf 0xbd
+ // the LaTeX command \ucr has been defined in doxygen.sty
+ if ((unsigned char)*(p) == 0xbf && (unsigned char)*(p+1) == 0xbd)
+ {
+ t << "{\\ucr}";
+ p += 2;
+ }
+ else
+ t << (char)c;
+ break;
case '#': t << "\\#"; break;
case '$': t << "\\$"; break;
case '%': t << "\\%"; break;
@@ -8865,19 +8885,10 @@ void writeLatexSpecialFormulaChars(FTextStream &t)
sup3[1]= 0xB3;
sup3[2]= 0;
- t << "\\ifthenelse{\\isundefined{\\DeclareUnicodeCharacter}}{%\n"
- " \\catcode`\\" << pminus << "=13% Superscript minus\n"
- " \\def" << pminus << "{${}^{-}$}\n"
- " \\catcode`\\" << psup2 << "=13% Superscript two\n"
- " \\def" << psup2 << "{${}^{2}$}\n"
- " \\catcode`\\"<<psup3<<"=13% Superscript three\n"
- " \\def"<<psup3<<"{${}^{3}$}\n"
- "}{%\n"
- " \\DeclareUnicodeCharacter{207B}{${}^{-}$}% Superscript minus\n"
- " \\DeclareUnicodeCharacter{C2B2}{${}^{2}$}% Superscript two\n"
- " \\DeclareUnicodeCharacter{C2B3}{${}^{3}$}% Superscript three\n"
- " \\DeclareUnicodeCharacter{2212}{-}% Just a minus sign\n"
- "}\n"
+ t << "\\usepackage{newunicodechar}\n"
+ " \\newunicodechar{" << pminus << "}{${}^{-}$}% Superscript minus\n"
+ " \\newunicodechar{" << psup2 << "}{${}^{2}$}% Superscript two\n"
+ " \\newunicodechar{" << psup3 << "}{${}^{3}$}% Superscript three\n"
"\n";
}