c# - Save Chinese, Arabic, English etc characters in file -


I have a file that contains English, Chinese and Arabic characters. Now when I have read the text of this file in the string So all the text shows correctly, but when I save that file in another file, it removes all my English and Arabic characters and only removes the remaining parts of English characters.

I am using the code to read the file

  string content = file. ReadList (server.mappath ("myfile1.xml"));   

The code below I'm using to write it in another file

  file. WrightAllText (Server.MapPath (myfile2.xml), content);   

When I open myfile2.xml in Visual Studio, it does not show Chinese and Arabic characters, but in myfile1.xml it does. Even if I copy the contents of myfile1.xml to myfile2.xml, myfile2.xml shows all the characters even then.

I do not know why this is not working if I'm using the above code. /p>

Specify the UTF8 encoding when you type a file, which is used by your Chinese and Arabic characters:

  file. Write all text (server.MapPath (myfile2.xml), content, encoding. UTF8);   

From:

UTF-8 can convert any Unicode character to encode. ... For example, special code can be added to switch encoding or without the manual settings, Chinese and Arabic can be supported (in the same text).

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -