c# - Any idea how to enforce utf8 within a document -
i creating xml document , atttempting store @ utf8. however, receiving non utf8 apostrophe within stored document.
eg : <name=dave t="owner(e.g pete’s)">
i have tried follwoing
`system.text.utf8encoding encoding = new system.text.utf8encoding(); var docx = encoding.getbytes(vdd.tostring()); system.io.streamwriter s = new streamwriter(pathandfilename, false, encoding); string mystring = encoding.getstring(docx); s.write(mystring);
`
which should have been overkill, '’' inside of brackets still showing. have tried htmlencode, didn't help.
the xml reads fine utf8 in notepad++, ’ character not parsing on of clients systems.
help please.....
edit: dour noted missed in confusion; sample pasted not xml @ all, , therefore not parse. answer still applies insofar 'html encoding' , utf8 encoding wrong roads going down here.
it's difficult tell problem is, i've tried eliminate of possibilities , come possibility: ’
causing xml not parsed correctly.
this not encoding problem. skeet notes, utf8 can represent unicode characters, including one. instead, an... umm... encoding problem. is: xml data encoding problem.
the character should attribute encoded, not html encoded
what api using build xml? should done you, don't need worry encode, how, , why. if attribute encode ’
character, think problem cease.
assuming understand problem...
Comments
Post a Comment