ホーム > ライブラリ > String > fString_Unvisible_to_Visible

ライブラリ

fString_Unvisible_to_Visible

***************************************************************
デバッグ用。
[?]や[・]等と表示されたり, 表示されない制御文字を
見えるようあぶり出す。
例:タブを「[Tab]」等と表示

【引数】Value :対象の文字列
***************************************************************

Public Function fString_Unvisible_to_Visible(Value As String) As String
'+ 制御文字や、目視不能な文字列を、目視可能にする
    
    If Value = "" Then Exit Function
    
    Dim Dic_Unvisible   As Scripting.Dictionary
    Set Dic_Unvisible = prDic_Unvisible
    
    Dim Strs()  As String
    ReDim Strs(1 To Len(Value))
    
    Dim i   As Long
    For i = LBound(Strs, 1) To UBound(Strs, 1)
        
        Dim Char    As String
        Char = Mid$(Value, i, 1)
        
        If Dic_Unvisible.Exists(Char) = True Then
            Strs(i) = Dic_Unvisible.Item(Char)
        Else
            Strs(i) = Char
        End If
        
    Next
    
    fString_Unvisible_to_Visible = Join(Strs, "")
    
    Set Dic_Unvisible = Nothing
    
End Function

Private Function prDic_Unvisible() As Scripting.Dictionary
    
    Dim Dic As Scripting.Dictionary
    Set Dic = New Scripting.Dictionary
    
    Dim i   As Long
    For i = 0 To 128
        
        Dim View    As String
        Select Case Chr(i)
        Case Chr(0):    View = "[NullChar]" '値0を持つ文字
        Case Chr(1):    View = "[Start Of Heading]"
        Case Chr(2):    View = "[Start Of Text]"
        Case Chr(3):    View = "[End Of Text]"
        Case Chr(4):    View = "[End Of Transmission]"
        Case Chr(5):    View = "[Enquery]"
        Case Chr(6):    View = "[Acknowledgement]"
        Case Chr(7):    View = "[Bell]"
        Case Chr(8):    View = "[Back Space]"
        Case Chr(9):    View = "[Tab]"
        Case Chr(10):   View = "[Lf]"
        Case Chr(11):   View = "[VerticalTab]"
        Case Chr(12):   View = "[FormFeed]"
        Case Chr(13):   View = "[Cr]"
        Case Chr(14):   View = "[Shift Out]"
        Case Chr(15):   View = "[Shift In]"
        Case Chr(16):   View = "[Data Link Escape]"
        Case Chr(17):   View = "[Device Control 1]"
        Case Chr(18):   View = "[Device Control 2]"
        Case Chr(19):   View = "[Device Control 3]"
        Case Chr(20):   View = "[Device Control 4]"
        Case Chr(21):   View = "[Negative Acknowledgement]"
        Case Chr(22):   View = "[Synchronous idle]"
        Case Chr(23):   View = "[End of Transmission Block]"
        Case Chr(24):   View = "[Cancel]"
        Case Chr(25):   View = "[End of Medium]"
        Case Chr(26):   View = "[End Of File]"
        Case Chr(27):   View = "[Escape]"
        Case Chr(28):   View = "[File Sepalator]"
        Case Chr(29):   View = "[Group Sepalator]"
        Case Chr(30):   View = "[Record Sepalator]"
        Case Chr(31):   View = "[Unit Sepalator]"
        Case Chr(32):   View = "[Space]"
        Case " ":      View = "[SpaceW]"
        Case Chr(127):  View = "[Delete]"
        Case Chr(128):  View = "[Chr(128)]"
        
        Case Else:      View = ""
        End Select
        
        If View <> "" Then
            Dic.Item(Chr(i)) = View
        End If
                
    Next
    
    Set prDic_Unvisible = Dic
    Set Dic = Nothing
    
End Function
 

String   2017/11/21   shono

この記事へのコメント

コメントを送る

 
※ メールは公開されません
Loading...
 画像の文字を入力してください