| |

VerySource

 Forgot password?
 Register
Search
Author: xiali33

Help! UTF-8 GB2312 format problem.

[Copy link]

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-6-12 09:45:01
| Show all posts
System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("bb.xml"), false, System.Text.Encoding.Default);

doc.Save(sw);

After rewriting in this way, the Chinese garbled problem was indeed solved, but it was automatically loaded at the generated file header
<?xml version="1.0" encoding="utf-8"?>, this sentence can’t let it come out, once it comes out, it’s wrong
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-6-16 14:30:01
| Show all posts
After rewriting in this way, the Chinese garbled problem was indeed solved, but it was automatically loaded at the generated file header
<?xml version="1.0" encoding="utf-8"?>, this sentence can’t let it come out, once it comes out, it’s wrong

=========

Directly use streamwrite to save.
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-6-16 18:30:01
| Show all posts
Using dom is superfluous.




string strXML = null;

strXML = "<ASX version=\"3.0\">";

for(int i = 0; i <10; i++)
{
strXML += "<Entry>"
+"<Ref href=\""
+"DD工"
+"\"/></Entry>";

}
The
strXML += "</ASX>";

The

The
System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("cc.xml"), false, System.Text.Encoding.Default);

sw.Write(strXML);
sw.Close();
Reply

Use magic Report

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-6-17 15:45:01
| Show all posts
Really thanks! It is indeed so solved!
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