c# - load foreign characters from xml file using StreamReader -


am loading xml file @ same time there greek characters inside file "ναι" , when load them on data grid view table appear ���.

am using xmlreader load encoding iso-8859-7 like

public xmldocument loaddocument(string x) {     xmldocument document = new xmldocument();     using (streamreader stream = new streamreader(x, encoding.getencoding("iso-8859-7")))     {         document.load(stream);      }     return (document); } 

the simplest answer here not use streamreader @ all. let xml parser handle encoding appropriately:

public xmldocument loaddocument(string x) {     xmldocument document = new xmldocument();     using (var stream = file.openread(x))     {         document.load(stream);      }     return document; } 

or use xmldocument.load(string):

public xmldocument loaddocument(string x) {     xmldocument document = new xmldocument();     document.load(x);     return document; } 

the xml document should specify encoding in xml declaration if needs - , that's best source of truth.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -