Strange character

  • Thread starter Thread starter USCG
  • Start date Start date
U

USCG

My mini-application pings various machines and writes the
result to a text file.

There is a cosmetic quirk I am troubled with though.
When I look at the text file output, at the end of each
line there is a strange character that looks like a
musical note. Should I be concerned about this? Here is
my code for reference.

Imports System.IO
Module Module1
Sub Main()
Dim fs As New FileStream("Results.txt",
FileMode.Create, FileAccess.Write)
Dim s As New StreamWriter(fs)
s.BaseStream.Seek(0, SeekOrigin.End)
Dim pr As New System.Diagnostics.Process
pr.StartInfo.CreateNoWindow = True
pr.StartInfo.FileName = "ping.exe"
pr.StartInfo.Arguments = "-w 1 10.33.36.5"
pr.StartInfo.RedirectStandardOutput = True
pr.StartInfo.RedirectStandardError = False
pr.StartInfo.UseShellExecute = False
pr.Start()
Dim strOut As String = pr.StandardOutput.ReadToEnd
()
pr.WaitForExit()
s.WriteLine(strOut)
s.Close()
End Sub
End Module
 
USCG said:
There is a cosmetic quirk I am troubled with though.
When I look at the text file output, at the end of each
line there is a strange character that looks like a
musical note. Should I be concerned about this? Here is
my code for reference.

Imports System.IO
Module Module1
Sub Main()
Dim fs As New FileStream("Results.txt",
FileMode.Create, FileAccess.Write)
Dim s As New StreamWriter(fs)
s.BaseStream.Seek(0, SeekOrigin.End)
Dim pr As New System.Diagnostics.Process
pr.StartInfo.CreateNoWindow = True
pr.StartInfo.FileName = "ping.exe"
pr.StartInfo.Arguments = "-w 1 10.33.36.5"
pr.StartInfo.RedirectStandardOutput = True
pr.StartInfo.RedirectStandardError = False
pr.StartInfo.UseShellExecute = False
pr.Start()
Dim strOut As String = pr.StandardOutput.ReadToEnd

I assume that you are using the wrong encoding for reading the text:

<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip>
 
Your application is interesting, thanks, but when I open
my file with something other than the MS-DOS prompt,
the "musical notes" aren't there, and the formatting
appears as I expect.

Is this a command-prompt...quirk?
 
Hi,

When you debug the output, you have a double 'carriage return/line feed'
(hex 0D) at the end of each line followed by hex 0A. This combination is
evidently displaying the ascii character you see when you 'edit
results.txt'. This may simply be a bug in standardoutput.readtoend. You
could probably test this by using a hex editor and deleting the 0A byte,
just to see what happens.

Bernie Yaeger
 
Back
Top