diff options
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/src/util.cpp b/src/util.cpp index ea68cd7..b387a84 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -5290,6 +5290,22 @@ QCString substitute(const QCString &s,const QCString &src,const QCString &dst,in return result; } +/// substitute all occurrences of \a srcChar in \a s by \a dstChar +QCString substitute(const QCString &s,char srcChar,char dstChar) +{ + int l=s.length(); + QCString result(l+1); + char *q=result.rawData(); + if (l>0) + { + const char *p=s.data(); + char c; + while ((c=*p++)) *q++ = (c==srcChar) ? dstChar : c; + } + *q='\0'; + return result; +} + //---------------------------------------------------------------------- QCString substituteKeywords(const QCString &s,const char *title, @@ -6725,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; @@ -6746,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; @@ -7913,8 +7949,8 @@ bool readInputFile(const char *fileName,BufStr &inBuf,bool filter,bool isSourceC int start=0; if (size>=2 && - ((inBuf.at(0)==-1 && inBuf.at(1)==-2) || // Little endian BOM - (inBuf.at(0)==-2 && inBuf.at(1)==-1) // big endian BOM + (((uchar)inBuf.at(0)==0xFF && (uchar)inBuf.at(1)==0xFE) || // Little endian BOM + ((uchar)inBuf.at(0)==0xFE && (uchar)inBuf.at(1)==0xFF) // big endian BOM ) ) // UCS-2 encoded file { @@ -8830,6 +8866,32 @@ void writeExtraLatexPackages(FTextStream &t) } } +void writeLatexSpecialFormulaChars(FTextStream &t) +{ + unsigned char minus[4]; // Superscript minus + char *pminus = (char *)minus; + unsigned char sup2[3]; // Superscript two + char *psup2 = (char *)sup2; + unsigned char sup3[3]; + char *psup3 = (char *)sup3; // Superscript three + minus[0]= 0xE2; + minus[1]= 0x81; + minus[2]= 0xBB; + minus[3]= 0; + sup2[0]= 0xC2; + sup2[1]= 0xB2; + sup2[2]= 0; + sup3[0]= 0xC2; + sup3[1]= 0xB3; + sup3[2]= 0; + + t << "\\usepackage{newunicodechar}\n" + " \\newunicodechar{" << pminus << "}{${}^{-}$}% Superscript minus\n" + " \\newunicodechar{" << psup2 << "}{${}^{2}$}% Superscript two\n" + " \\newunicodechar{" << psup3 << "}{${}^{3}$}% Superscript three\n" + "\n"; +} + //------------------------------------------------------ static int g_usedTableLevels = 0; |