summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-12-16 19:20:30 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-12-16 19:20:30 (GMT)
commit9aa686d120c457479621b3fc1525165d936c6669 (patch)
tree9b4ebf103c057c6dac5a8eaff4cf375eec1d413f
parent7b2e841b3a3d7d787458f236e2447c890cfbf590 (diff)
parent2421a8bb57aad7bbd43dd992d385a59006004f42 (diff)
downloadDoxygen-9aa686d120c457479621b3fc1525165d936c6669.zip
Doxygen-9aa686d120c457479621b3fc1525165d936c6669.tar.gz
Doxygen-9aa686d120c457479621b3fc1525165d936c6669.tar.bz2
Merge branch 'feature/bug_utf_8_latex_href' of https://github.com/albert-github/doxygen into albert-github-feature/bug_utf_8_latex_href
-rw-r--r--src/util.cpp58
1 files changed, 57 insertions, 1 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 4a35517..e086dad 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -5309,7 +5309,63 @@ QCString latexFilterURL(const char *s)
case '%': t << "\\%"; break;
case '\\': t << "\\\\"; break;
default:
- t << c;
+ if (c<0)
+ {
+ char ids[5];
+ const unsigned char uc = (unsigned char)c;
+ bool doEscape = TRUE;
+ if (uc <= 0xf7)
+ {
+ const signed char* pt = (signed char *)p;
+ ids[ 0 ] = c;
+ int l = 0;
+ if ((uc&0xE0)==0xC0)
+ {
+ l=2; // 11xx.xxxx: >=2 byte character
+ }
+ if ((uc&0xF0)==0xE0)
+ {
+ l=3; // 111x.xxxx: >=3 byte character
+ }
+ if ((uc&0xF8)==0xF0)
+ {
+ l=4; // 1111.xxxx: >=4 byte character
+ }
+ doEscape = l==0;
+ for (int m=1; m<l && !doEscape; ++m)
+ {
+ unsigned char ct = (unsigned char)*pt;
+ if (ct==0 || (ct&0xC0)!=0x80) // invalid unicode character
+ {
+ doEscape=TRUE;
+ }
+ else
+ {
+ ids[ m ] = *pt++;
+ }
+ }
+ if ( !doEscape ) // got a valid unicode character
+ {
+ static char map[] = "0123456789ABCDEF";
+ for (int m = 0; m < l; ++m)
+ {
+ unsigned char id = (unsigned char)ids[m];
+ t << "\\%" << map[id>>4] << map[id&0xF];
+ }
+ p += l - 1;
+ }
+ }
+ if (doEscape) // not a valid unicode char or escaping needed
+ {
+ static char map[] = "0123456789ABCDEF";
+ unsigned char id = (unsigned char)c;
+ t << c;
+ }
+ }
+ else
+ {
+ t << c;
+ }
break;
}
}