UWP methods
Async voidDownload () {/*New HttpClient*/HttpClient web_=NewHttpClient (); /*download using HttpClient's Getasync method*/ varres =awaitWeb_. Getasync (NewUri ("Http://dzs.qisuu.com/txt/%E6%AD%A6%E9%81%93%E7%B3%BB%E7%BB%9F%E4%B9%8B%E8%8D%89%E6%B0%91%E5%B4%9B%E8%B5%B7.txt")); /*registering the character encoding that the desktop program can use*/Encoding.registerprovider (codepagesencodingprovider.instance); /*Register GBK*/Encoding ENCODINGGBK= Encoding.GetEncoding ("GBK"); /*Conversion Encoding*/Stream Streamtoreader=awaitRes. Content.readasstreamasync (); /*using a new instance of StreamReader: Stream flow, character encoding*/StreamReader SR=NewStreamReader (STREAMTOREADER,ENCODINGGBK); /*asynchronously reads all characters*/ stringText =awaitSr. Readtoendasync (); /*Assigning a value to a TextBox control*/T.text+=Text; }
:
WP8.1 Method:
New HttpClient (); var await web_. Getasync (Thenew Uri ("http://dzs.qisuu.com/txt/%E6%AD%A6%E9%81%93%E7%B3%BB%E7%BB%9F%E4%B9%8B% E8%8d%89%e6%b0%91%e5%b4%9b%e8%b5%b7.txt")); /* Convert characters */ var await Res. Content.readasstringasync (); = Text;
Above is the workaround. No matter what method you use to read characters, or Web pages. In the UWP, be sure to convert to stream and register GBK, which is read through Steramreader. WP8.1 is relatively simple, both methods (UWP and WP8.1) are available.
uwp&wp8.1 Chinese Web page character garbled characters garbled UTF-8 turn GBK resolution method