Created
July 1, 2019 16:13
-
-
Save sholfen/2ab1efc10ecbd6c7deea171f8db97890 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpClient client = new HttpClient(); | |
client.BaseAddress = new Uri(@"https://www.google.com.tw"); | |
var response = await client.GetAsync(@"/"); | |
response.Content.Headers.ContentType.CharSet = "utf-8"; | |
//string result = await response.Content.ReadAsStringAsync(System.Text.Encoding.UTF8); | |
//string result = await response.Content.ReadAsStringAsync(); | |
byte[] byteArray = await response.Content.ReadAsByteArrayAsync(); | |
string result = System.Text.Encoding.UTF8.GetString(byteArray, 0, byteArray.Length); | |
result = System.Text.Encoding.GetEncoding("utf-8").GetString(byteArray); | |
Console.WriteLine(System.Web.HttpUtility.UrlDecode(result)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment