Improve the rendering of the control characters greatly by using

the Unicode counterparts in th 0x24## plane and add a little bit
of explanation what we are doing there and why we are doing this.
feature.diff-whitespace
Thomas Keller 2011-10-09 00:55:42 +02:00
parent 2e0995abac
commit 7438a2bf19
2 changed files with 9 additions and 3 deletions

View File

@ -247,8 +247,16 @@ class IDF_Diff
private static function makeNonPrintableCharsVisible($line)
{
// This translates most of the C0 ASCII control characters into
// their visual counterparts in the 0x24## unicode plane
// (http://en.wikipedia.org/wiki/C0_and_C1_control_codes).
// We could add DEL (0x7F) to this set, but unfortunately this
// is not nicely mapped to 0x247F in the control plane, but 0x2421
// and adding an if expression below just for this is a little bit
// of a hassle. And of course, the more esoteric ones from C1 are
// missing as well...
return preg_replace('/([\x00-\x1F])/ue',
'"<span class=\"non-printable\" title=\"0x".strtoupper(bin2hex("\\1"))."\">".bin2hex("\\1")."</span>"',
'"<span class=\"non-printable\" title=\"0x".bin2hex("\\1")."\">&#x24".bin2hex("\\1")."</span>"',
$line);
}

View File

@ -663,8 +663,6 @@ table.diff-contents td > span.non-printable {
color: white;
text-transform: uppercase;
float: none;
font-size: 5.5pt;
font-family: Calibri, Helvetica, Arial, sans-serif;
text-align: center;
display: inline-block;
padding: 1px 1px 0px 1px;