paul1956 / CSharpToVB

New version of CSharpToVB converter
MIT License
25 stars 9 forks source link

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

Open VBAndCs opened 2 years ago

VBAndCs commented 2 years ago

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};" 
}