Link to home
Create AccountLog in
Avatar of mcsdguyian
mcsdguyianFlag for United States of America

asked on

VB.NET Open File and Keep Characters Intact Just Like Notepad

Hi,

I am trying to incorporate a seemly easy feature into a program to convert some older files to a new format and am having issues opening the files and keeping the original characters intact.

an example of the character string for conversion is below(minus the quotes)
"2  13.0000•©                0.5000    0.5000   13.1757     "

The 2 character that need to be converted are the "•©" these character appear perfectly fine when they are opened in notepad, but when using a streamreader to pull them in to VB.NET they do not appear properly their formatting is changed to 2 squares.

Any help would be appreciated, I am kinda stumped right now.
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Avatar of mcsdguyian

ASKER

Unfortunately  I have tried that and in the example code it detects as Encoding.ASCII with when it pull s the file into the textbox it displays the special characters as "??" and not as "•©"

Since it does that I have no way of determining that those are the 2 characters that need to be converted.  All I have to detect those characters and convert to the new characters is the following line

txtConvertTo.Text = txtConvertFrom.Text.Replace(Chr(149) + Chr(169), Chr(210))

I setup a test to make sure it works by pasting the special characters "•©" from the file directly to a VB.Net textbox and running that line of code and it works fine.  It just can't opening the file automatically and pull it in with the right encoding or something else.
ASKER CERTIFIED SOLUTION
Avatar of mcsdguyian
mcsdguyian
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
The streamreader use the Encoding.Default when encoding is not used.