I have a VirtualPathProvider that takes the source code from my DB as a simple string and encodes it as UTF8.
For instance:
public override Stream Open() { MemoryStream result = new MemoryStream(); result = new MemoryStream(Encoding.UTF8.GetBytes(_sourceCode)); return result; }
Then I have the main page of the layout, which has its own encoding as UTF 8
<meta charset="utf-8">
Then the master page calls @RenderBody() , which receives my VirtualPathProvider page and displays it in the browser.
The problem is that it displays a page with its encoded characters:
wünschte becomes wünschte
What am I doing wrong?
TL; DR:
I want wünschte to appear instead of wünschte. A simple line from the database is wünschte, but as soon as it comes from the memory stream to my page, it becomes wÃnchte.
source share