Page MenuHomePhabricator

D16541.id39804.diff
No OneTemporary

D16541.id39804.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1652,6 +1652,7 @@
'PHUIInfoPanelExample' => 'applications/uiexample/examples/PHUIInfoPanelExample.php',
'PHUIInfoPanelView' => 'view/phui/PHUIInfoPanelView.php',
'PHUIInfoView' => 'view/form/PHUIInfoView.php',
+ 'PHUIInvisibleCharacterView' => 'view/phui/PHUIInvisibleCharacterView.php',
'PHUIListExample' => 'applications/uiexample/examples/PHUIListExample.php',
'PHUIListItemView' => 'view/phui/PHUIListItemView.php',
'PHUIListView' => 'view/phui/PHUIListView.php',
@@ -6319,6 +6320,7 @@
'PHUIInfoPanelExample' => 'PhabricatorUIExample',
'PHUIInfoPanelView' => 'AphrontView',
'PHUIInfoView' => 'AphrontView',
+ 'PHUIInvisibleCharacterView' => 'AphrontView',
'PHUIListExample' => 'PhabricatorUIExample',
'PHUIListItemView' => 'AphrontTagView',
'PHUIListView' => 'AphrontTagView',
diff --git a/src/view/phui/PHUIInvisibleCharacterView.php b/src/view/phui/PHUIInvisibleCharacterView.php
new file mode 100644
--- /dev/null
+++ b/src/view/phui/PHUIInvisibleCharacterView.php
@@ -0,0 +1,87 @@
+<?php
+
+/**
+ * API for replacing whitespace characters and some control characters with
+ * their printable representations. This is useful for debugging and
+ * displaying more helpful error messages to users.
+ *
+ */
+final class PHUIInvisibleCharacterView extends AphrontView {
+
+ private $inputText;
+
+ // This can almost certainly be pared down or simplified
+ private static $invisibleChars = array(
+ "\x00" => 'NULL',
+ "\x01" => 'START OF HEADER',
+ "\x02" => 'START OF TEXT',
+ "\x03" => 'END OF TEXT',
+ "\x04" => 'END OF TRANSMISSION',
+ "\x05" => 'ENQUIRY',
+ "\x06" => 'ACKNOWLEDGE',
+ "\x07" => 'BELL',
+ "\x08" => 'BACKSPACE',
+ "\x09" => 'TAB',
+ "\x0a" => 'NEWLINE',
+ "\x0b" => 'VERTICAL TAB',
+ "\x0c" => 'FORM FEED',
+ "\x0d" => 'CARRIAGE RETURN',
+ "\x0e" => 'SHIFT OUT',
+ "\x0f" => 'SHIFT IN',
+ "\x10" => 'DATA LINK ESCAPE',
+ "\x11" => 'DEVICE CONTROL 1',
+ "\x12" => 'DEVICE CONTROL 2',
+ "\x13" => 'DEVICE CONTROL 3',
+ "\x14" => 'DEVICE CONTROL 4',
+ "\x15" => 'NEG ACKNOWLEDGE',
+ "\x16" => 'SYNCHRONOUS IDLE',
+ "\x17" => 'END OF TRANS. BLOCK',
+ "\x18" => 'CANCEL',
+ "\x19" => 'END OF MEDIUM',
+ "\x1a" => 'SUBSTITUTE',
+ "\x1b" => 'ESCAPE',
+ "\x1c" => 'FILE SEPARATOR',
+ "\x1d" => 'GROUP SEPARATOR',
+ "\x1e" => 'RECORD SEPARATOR',
+ "\x1f" => 'UNIT SEPARATOR',
+ "\x20" => 'SPACE',
+ "\xc2\xa0" => 'NO-BREAK SPACE',
+ "\xe1\x9a\x80" => 'OGHAM SPACE MARK',
+ "\xe2\x80\x80" => 'EN QUAD',
+ "\xe2\x80\x81" => 'EM QUAD',
+ "\xe2\x80\x82" => 'EN SPACE',
+ "\xe2\x80\x83" => 'EM SPACE',
+ "\xe2\x80\x84" => 'THREE-PER-EM SPACE',
+ "\xe2\x80\x85" => 'FOUR-PER-EM SPACE',
+ "\xe2\x80\x86" => 'SIX-PER-EM SPACE',
+ "\xe2\x80\x87" => 'FIGURE SPACE',
+ "\xe2\x80\x88" => 'PUNCTUATION SPACE',
+ "\xe2\x80\x89" => 'THIN SPACE',
+ "\xe2\x80\x8a" => 'HAIR SPACE',
+ "\xe2\x80\x8b" => 'ZERO WIDTH SPACE',
+ "\xe2\x80\xaf" => 'NARROW NO-BREAK SPACE',
+ "\xe2\x81\x9f" => 'MEDIUM MATHEMATICAL SPACE',
+ "\xe3\x80\x80" => 'IDEOGRAPHIC SPACE',
+ );
+
+ public function __construct($input_text) {
+ $this->inputText = $input_text;
+ }
+
+ public function render() {
+ $input_text = $this->inputText;
+ $text_array = str_split($input_text);
+ for ($i = 0; $i < count($text_array); $i++) {
+ $char = $text_array[$i];
+ if (array_key_exists($char, self::$invisibleChars)) {
+ $text_array[$i] = phutil_tag(
+ 'span',
+ array('class' => 'invisible-special'),
+ '<'.self::$invisibleChars[$char].'>');
+
+ }
+ }
+ return $text_array;
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 11, 4:38 AM (1 w, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6735082
Default Alt Text
D16541.id39804.diff (3 KB)

Event Timeline