簡體   English   中英

字符串轉義轉換vb.net

[英]string escape conversion vb.net

我需要將此字符串轉換為我的vb,net代碼中的正確形式

if (c == '"') {
s.Append('"');
} else if (c == '\\') {
s.Append('\\');
} else if (c == '/') {
s.Append('/');
} else if (c == 'b') {
s.Append('\b');
} else if (c == 'f') {
s.Append('\f');
} else if (c == 'n') {
s.Append('\n');
} else if (c == 'r') {
s.Append('\r');
} else if (c == 't') {
s.Append('\t');
} else if (c == 'u') {

這被不適當地轉換為

If c = """"c Then
    s.Append(""""c)
ElseIf c = "\"c Then
    s.Append("\"c)
ElseIf c = "/"c Then
    s.Append("/"c)
ElseIf c = "b"c Then
    s.Append(ControlChars.Back)
ElseIf c = "f"c Then
    s.Append(ControlChars.FormFeed)
ElseIf c = "n"c Then
    s.Append(ControlChars.Lf)
ElseIf c = "r"c Then
    s.Append(ControlChars.Cr)
ElseIf c = "t"c Then
    s.Append(ControlChars.Tab)
ElseIf c = "u"c Then

有人可以幫我做正確的字符串轉義碼

謝謝

編輯

到目前為止,所有幫助我的人都感激不盡,但主要問題是

您如何在vb中這樣引用'"' ,因為我在這里不能使用單引號

轉換后的代碼是正確的。 如果使您感到更舒適,則可以使用ChrW(34):

    If c = ChrW(34) Then
        s.Append(ChrW(34))
    '' etc...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM