{"id":1533,"date":"2007-06-14T21:39:35","date_gmt":"2007-06-15T00:39:35","guid":{"rendered":"http:\/\/www.hoogervorst.ca\/arthur\/?p=1533"},"modified":"2007-10-06T09:23:37","modified_gmt":"2007-10-06T12:23:37","slug":"hey-hey","status":"publish","type":"post","link":"http:\/\/www.hoogervorst.ca\/arthur\/?p=1533","title":{"rendered":"Hey, hey."},"content":{"rendered":"<p><span class=\"dropcap\">T<\/span>oday, I discovered that the StringReaders\/Writers in .Net only support UTF-16 encoding, which may lead to some breakage if you&#8217;re using it in combination with the XMLSerializer object.\n<\/p>\n<p>If you really need to maintain UTF-8 compatibility, you should use a MemoryStream. This is actually just as simple as using a StringReader:\n<\/p>\n<p><pre>\r\n  MemoryStream m = new MemoryStream();\r\n  try\r\n  {\r\n    XmlSerializer formatter = \r\n        new XmlSerializer(typeof(TMakeUpYourMind));\r\n    formatter.Serialize(m, this);\r\n    m.Flush();\r\n    m.Seek(0, 0);\r\n    StreamReader rd = new StreamReader(m);\r\n    try\r\n    {\r\n      res = rd.ReadToEnd();\r\n    }\r\n    finally\r\n    {\r\n      rd.Dispose();\r\n    }\r\n  }\r\n  finally\r\n  {\r\n    m.Dispose();\r\n  }\r\n<\/pre>\n<\/p>\n<p>Don&#8217;t forget to &#8216;rewind&#8217; the stream to position 0.\n<\/p>\n<p>I&#8217;m not sure why this isn&#8217;t mentioned in the SDK. Also note to the Visual Studio Express developers: please make this weekly  &#8216;registration of Visual Studio Express&#8217; on my computer stop. I&#8217;m sure it&#8217;s a bug because everytime I register I get the same e-mail in with the same deals. I&#8217;ve already got 12 of them. Please.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, I discovered that the StringReaders\/Writers in .Net only support UTF-16 encoding, which may lead to some breakage if you&#8217;re using it in combination with the XMLSerializer object. If you really need to maintain UTF-8 compatibility, you should use a &hellip; <a href=\"http:\/\/www.hoogervorst.ca\/arthur\/?p=1533\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[88],"_links":{"self":[{"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/posts\/1533"}],"collection":[{"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1533"}],"version-history":[{"count":0,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=\/wp\/v2\/posts\/1533\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1533"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hoogervorst.ca\/arthur\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}