Private Sub testRevealString
Dim aString As String = $"This ${Chr(0x001B)} is a invisible character "$ 'note space at end which is also not visible
Log(aString)
Log(revealString(aString))
End Sub
Private Sub revealString(s As String) As String
Dim InvisibleChrs As String = $"
U+0000 NULL
U+0001 START OF HEADING (SOH)
U+0002 START OF TEXT (STX)
U+0003 END OF TEXT (ETX)
U+0004 END OF TRANSMISSION (EOT)
U+0005 END OF QUERY (ENQ)
U+0006 ACKNOWLEDGE (ACK)
U+0007 BEEP (BEL)
U+0008 BACKSPACE (BS)
U+0009 HORIZONTAL TAB (HT)
U+000A LINE FEED (LF)
U+000B VERTICAL TAB (VT)
U+000C FF (FORM FEED)
U+000D CR (CARRIAGE RETURN)
U+000E SO (SHIFT OUT)
U+000F SI (SHIFT IN)
U+0010 DATA LINK ESCAPE (DLE)
U+0011 DEVICE CONTROL 1 (DC1)
U+0012 DEVICE CONTROL 2 (DC2)
U+0013 DEVICE CONTROL 3 (DC3)
U+0014 DEVICE CONTROL 4 (DC4)
U+0015 NEGATIVE ACKNOWLEDGEMENT (NAK)
U+0016 SYNCHRONIZE (SYN)
U+0017 END OF TRANSMISSION BLOCK (ETB)
U+0018 CANCEL (CAN)
U+0019 END OF MEDIUM (EM)
U+001A SUBSTITUTE (SUB)
U+001B ESCAPE (ESC)
U+001C FILE SEPARATOR (FS) RIGHT ARROW
U+001D GROUP SEPARATOR (GS) LEFT ARROW
U+001E RECORD SEPARATOR (RS) UP ARROW
U+001F UNIT SEPARATOR (US) DOWN ARROW
U+001F SPACE
U+0009 CHARACTER TABULATION
U+00A0 NO-BREAK SPACE
U+00AD SOFT HYPHEN
U+034F COMBINING GRAPHEME JOINER
U+061C ARABIC LETTER MARK
U+115F HANGUL CHOSEONG FILLER
U+1160 HANGUL JUNGSEONG FILLER
U+17B4 KHMER VOWEL INHERENT AQ
U+17B5 KHMER VOWEL INHERENT AA
U+180E MONGOLIAN VOWEL SEPARATOR
U+2000 EN QUAD
U+2001 EM QUAD
U+2002 EN SPACE
U+2003 EM SPACE
U+2004 THREE-PER-EM SPACE
U+2005 FOUR-PER-EM SPACE
U+2006 SIX-PER-EM SPACE
U+2007 FIGURE SPACE
U+2008 PUNCTUATION SPACE
U+2009 THIN SPACE
U+200A HAIR SPACE
U+200B ZERO WIDTH SPACE
U+200C ZERO WIDTH NON-JOINER
U+200D ZERO WIDTH JOINER
U+200E LEFT-TO-RIGHT MARK
U+200F RIGHT-TO-LEFT MARK
U+202F NARROW NO-BREAK SPACE
U+205F MEDIUM MATHEMATICAL SPACE
U+2060 WORD JOINER
U+2061 FUNCTION APPLICATION
U+2062 INVISIBLE TIMES
U+2063 INVISIBLE SEPARATOR
U+2064 INVISIBLE PLUS
U+206A INHIBIT SYMMETRIC SWAPPING
U+206B ACTIVATE SYMMETRIC SWAPPING
U+206C INHIBIT ARABIC FORM SHAPING
U+206D ACTIVATE ARABIC FORM SHAPING
U+206E NATIONAL DIGIT SHAPES
U+206F NOMINAL DIGIT SHAPES
U+3000 IDEOGRAPHIC SPACE
U+2800 BRAILLE PATTERN BLANK
U+3164 HANGUL FILLER
U+FEFF ZERO WIDTH NO-BREAK SPACE
U+FFA0 HALFWIDTH HANGUL FILLER
"$
Private lookup As Map 'Make this global to avoid recreating it each time
If lookup.IsInitialized = False Then
lookup.Initialize
Dim v() As String = Regex.Split(CRLF, InvisibleChrs)
For Each t As String In v
t = t.Trim
If t.Length = 0 Then Continue
Dim hex As String = t.SubString2(2, 6)
Dim number As Int = Bit.ParseInt(hex, 16)
lookup.Put(number, hex)
Next
End If
Dim sb As StringBuilder
sb.Initialize
For i = 0 To s.Length - 1
Dim c As String = s.CharAt(i)
Dim cint As Int = Asc(c)
If lookup.ContainsKey(cint) Then
sb.Append("{0x").Append(lookup.Get(cint)).Append("}")
Else if i = s.Length - 1 And c= " " Then
sb.Append("{SPACE").Append("}")
Else
sb.Append(c)
End If
Next
Return sb.toString
End Sub