I have a piece of code that converts string into memory stream:
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(applicationForm)))
However I'm a bit confused if it's correct. Basically I'm always confused about .NET encoding.
Bottom line: do I use correct encoding object (UTF8) to get bytes?
I know that internally .NET stores string as UTF-16, but my applicationForm variable was based on file with text which was saved in UTF-8 encoding.
Thanks,Pawel
EDIT 1: Let's explain exactly how I get applicationForm variable. I do have access to assembly that exposes class with method GenerateApplicationForm. That method returns string. However I know, that somewhere behind the scenes, component uses files stored on drive.Content of those files are encoded using UTF-8. So I can't read file directly etc. I only have that string and I know, that originally, UTF-8 encoded file is used. In client code, the one that used GenerateApplicationForm component, I have to convert applicationForm variable into stream, cos other components (from another assembly) is expecting a Stream. That's where using.... statement mentioned in question springs into action.