c# - UrlEncode in dotnet-core with TextEncoding -


i have text retrieved web , saved file encoding 1252.

text has url's in emoji's. unless result method1 below, can not able retrieve pages.

since don't have system.web in , no support system.net.webutility textencoding, wonder, if there easy way handle issue?

var text = $"hello-world 🖤ðŸ’--œðŸ’œðŸ–";  encoding sourceencoding = encoding.getencoding(1252);  // method 1 // hello-world+%f0%9f%96%a4%f0%9f%92--%9c%f0%9f%92%9c%f0%9f%96 // <----- result, system.web.httputility.urlencode(text, sourceencoding).dump();  // method 2 // hello-world+%c3%b0%c5%b8%e2%80%93%c2%a4%c3%b0%c5%b8%e2%80%99--%c5%93%c3%b0%c5%b8%e2%80%99%c5%93%c3%b0%c5%b8%e2%80%93 system.web.httputility.urlencode(text).dump();  // method 3 // hello-world+%c3%b0%c5%b8%e2%80%93%c2%a4%c3%b0%c5%b8%e2%80%99--%c5%93%c3%b0%c5%b8%e2%80%99%c5%93%c3%b0%c5%b8%e2%80%93 system.net.webutility.urlencode(text).dump();  // method 4 // hello-world%20%c3%b0%c5%b8%e2%80%93%c2%a4%c3%b0%c5%b8%e2%80%99--%c5%93%c3%b0%c5%b8%e2%80%99%c5%93%c3%b0%c5%b8%e2%80%93 system.uri.escapeuristring(text).dump();  // method5 // hello-world%20%f0%9f%96%a4%ef%bf%bd--%ef%bf%bd%f0%9f%92%9c%ef%bf%bd system.uri.escapeuristring(encoding.utf8.getstring(sourceencoding.getbytes(text))).dump();  // method6 // hello-world+%f0%9f%96%a4%ef%bf%bd--%ef%bf%bd%f0%9f%92%9c%ef%bf%bd system.net.webutility.urlencode(encoding.utf8.getstring(sourceencoding.getbytes(text))).dump(); 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -