| |

VerySource

 Forgot password?
 Register
Search
View: 469|Reply: 8

How to read all text with special characters

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-24 12:20:01
| Show all posts |Read mode
With the following code

StreamReader sr = new StreamReader (lphyfilepath, Encoding.Default);
richTextBox1.Text = sr.ReadToEnd ();

Can't read all at all :(
Reply

Use magic Report

0

Threads

46

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-2-10 18:45:01
| Show all posts
Use binary (stream) method to read byte []
Reply

Use magic Report

1

Threads

23

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-2-10 22:00:01
| Show all posts
what. . . I can't see the notebook when it is open.
Reply

Use magic Report

0

Threads

14

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-2-11 01:15:01
| Show all posts
It may be related to Encoding. What encoding is used when saving 123.txt?
Reply

Use magic Report

0

Threads

56

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-2-11 15:30:01
| Show all posts
I tried it. I can read it. The content is "^ p"
I don't know what it means
You try again. The encoding is Encoding.Default.
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-11 23:45:01
| Show all posts
Has nothing to do with coding
Read all should show ^ p B U) w1u
There is a break character in front of B, making it impossible to read the whole
All can be read out under editplus, but can not be selected and copied. After copying and selecting all, you can only paste it after ^ p B) w1u is gone
Reply

Use magic Report

0

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-2-14 15:00:02
| Show all posts
Just circulate the output on the console yourself. Don't use notepad
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-2-15 03:00:02
| Show all posts
private void Form1_Load (object sender, EventArgs e)
        {
            // StreamReader sr = new StreamReader (@ "c:\123.txt");

            FileInfo fi = new FileInfo (@ "c:\123.txt");
            FileStream fs = File.Open (@ "c:\123.txt", FileMode.Open);
            byte [] fileContent = new byte [(int) fi.Length];
            fs.Read (fileContent, 0, (int) fi.Length);
            foreach (byte indiv in fileContent)
            {
                System.Diagnostics.Debug.WriteLine ("'" + indiv.ToString () + "': Code:" + Convert.ToChar (indiv) .ToString ());

            }
            string a = ""; // breakpoint here, see IDE output window content
        }
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-3-17 09:30:01
| Show all posts
Thanksstarsport
With your inspiration, it has been successfully completed ~!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list