我有以下代码的问题:
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
var content = reader.ReadToEnd();
ParserContext context = new ParserContext()
{
BaseUri = new Uri(Configuration.SkinsFolder)
//,XmlLang = "utf-8" // I have tried with this parameter and without it
};
var result = XamlReader.Parse(content, context);
return result;
}
Run Code Online (Sandbox Code Playgroud)
相应的xaml,出现问题:
...
<TextBlock>??????? ???????</TextBlock>
<TextBlock Text="?? ????" />
...
Run Code Online (Sandbox Code Playgroud)
在解析这个xaml期间,我得到了异常:
Invalid character in the given encoding. Line 76, position 167.
at System.Windows.Markup.XamlReaderHelper.RethrowAsParseException(String keyString, Int32 lineNumber, Int32 linePosition, Exception innerException)
at System.Windows.Markup.XamlReaderHelper.Read(XamlNode& xamlNode)
at System.Windows.Markup.XamlParser.ReadXaml(Boolean singleRecordMode) …Run Code Online (Sandbox Code Playgroud)