No, that's because DetectXmlDeclEncoding detected encoding. You can't read xml declaration from UTF-8 string if it actually contains UTF-32 data.