Skip to content

Instantly share code, notes, and snippets.

@sholfen
Created July 1, 2019 16:13
Show Gist options
  • Save sholfen/2ab1efc10ecbd6c7deea171f8db97890 to your computer and use it in GitHub Desktop.
Save sholfen/2ab1efc10ecbd6c7deea171f8db97890 to your computer and use it in GitHub Desktop.
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