Skip to content

Converting C# string literals to VB is missed up #84

@VBAndCs

Description

@VBAndCs

Try this:

string[] x = new[] {
"{\\rtf1\\ansi\\ansicpg\\lang1024\\noproof65001\\uc1 \\deff0{\\fonttbl{\\f0\\fnil\\fcharset0\\fprq1 Consolas;}}",
"\\fs24 ",
"\\cf0 {0}", 
"\\", 
"\\\\", 
"\\{",
"\\}",	
"{\\b ",
"\\cf{0} {1}{2}{3}{4}{5}",
"\\cf0 {0}","\\}",
"\\par ",
"{\\colortbl;\r\n",
"\\red{0}\\green{1}\\blue{2};"
}

Most string literals will not be translated correctly.

Dim x As String() = {
"{\rtf1{&H7}nsi{&H7}nsicpg\lang1024{vbLf}oproof65001\uc1 \deff0{{ChrW(12)}onttbl{{ChrW(12)}0{ChrW(12)}nil{ChrW(12)}charset0{ChrW(12)}prq1 Consolas;}}",
"{ChrW(12)}s24 ",
"{vbCr}f0 {0}",
"\",
"\",
"\{",
"\}",
"{{ChrW(&H8)} ",
"{vbCr}f{0} {1}{2}{3}{4}{5}",
"{vbCr}f0 {0}", "\}",
"\par ",
"{{vbCr}olortbl;",
"\red{0}\green{1}{ChrW(&H8)}lue{2};"}

The correct result should be:

Dim x() As String = { "{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}", 
"\fs24 ", 
"\cf0 {0}", 
"\", 
"\\", 
"\{", 
"\}", 
"{\b ", 
"\cf{0} {1}{2}{3}{4}{5}", 
"\cf0 {0}",
"\}", 
"\par ", 
"{\colortbl;" & vbCrLf, 
"\red{0}\green{1}\blue{2};" 
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions