urlencode

encode string to utf8

烈酒焚心 提交于 2019-12-25 03:24:15
问题 How can easily encode a string to utf8 using .NET (VB or C#)? For instance I need to encode a string like "This (is) my string" the result should be a string "This+%28is%29+my+string". TIA JP 回答1: This is URL encoding, not UTF8 encoding. Try this method: HttpUtility.UrlEncode(value) 回答2: It looks like what you need to do is URL encoding, not "encoding to UTF-8". For that, use string encodedString = System.Web.HttpUtility.UrlEncode(yourString) (UTF-8 is a mechanism for representing Unicode

Avoid URL Encoding

大兔子大兔子 提交于 2019-12-25 01:28:47
问题 I'm having an issue related to url encoding in my struts 2 application. I did some research but could not find the correct way to do this. My application prepares the url dynamically and gets the variable by querying the database. The valid URL that I'm expecting is http://www.test.com/language=english&numbers=X,Y,Z However, when on UI because of URL encoding i get the URL as below http://www.test.com/language=english&numbers=X%2CY%2CZ numbers is a single variable and database returns the

How to avoid that UriBuilder creates Uri with unencoded + sign in its query string?

試著忘記壹切 提交于 2019-12-24 19:13:42
问题 I have some trouble with the UriBuilder and Uri classes in .Net. I want to build my Uri with a UriBuilder, and then use the resulting Uri. However, I cant get it to correctly encode the plus sign in its query string? Here is a small code example: var ub = new UriBuilder(); ub.Query = "t=a%2bc"; Console.WriteLine(ub.Uri.ToString()); This example gives me http://localhost/?t=a+c , but I would expect that the plus sign was encoded to %2b like this http://localhost/?t=a%2bc otherwise I cant use

servelt request parameter value contains ampersand?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 12:53:09
问题 I have below the url. http://localhost:8080/servlet?user=John&message=hai&hello&recipient=scott In above url i have 3 request parameters as below. user=John message=hai&hello recipient=scott Here the problem is with message request parameter's value.because here its value contains ampersend (&). when i try request.getParameter("message") then i get only hai but not hai&hello . How can i solve this issue? Thanks! 回答1: Try this, instead ....&message=hi%26hello.... . I mean, encode it. [Edited]

Why need encode and decode urls?

爷,独闯天下 提交于 2019-12-24 10:57:20
问题 I have read the question Why do you need to encode URLs but I still confused: Why the W3C just allow more character could exist in URL?So it could avoid encoding? Why there is exist decode 回答1: The URL representation of characters may differ from the characters you have in your code. In other words, there is a specific grammar that defines how URLs are assembled. Special characters that are used in forming a URL need to be encoded so that they do not cause unexpected results. Now to answer

UrlEncode

 ̄綄美尐妖づ 提交于 2019-12-24 05:14:18
public static string UrlEncode( string str) { StringBuilder sb = new StringBuilder(); byte [] byStr = System.Text.Encoding.Default.GetBytes(str); for ( int i = 0 ; i < byStr.Length; i ++ ) { sb.Append( @" % " + Convert.ToString(byStr[i], 16 )); } return (sb.ToString()); } C#的一段返回UrlEncode加密格式的代码~ UrlEncode加密就是在网址中。。那个汉字加密成%xxx%xxx那样的 来源: https://www.cnblogs.com/shiweifu/archive/2008/01/13/1037217.html

How to use C# encode and decode 'Chinese' characters

梦想的初衷 提交于 2019-12-23 18:44:42
问题 In my ASP.NET MVC application i am using Chinese Category Name, it was displayed as %E8%82%B2%E5%84%BF in IE's URL address, but the actual value is '育儿'. I want to know how can I convert '育儿' into %E8%82%B2%E5%84%BF in C# and how can I convert it back, too. Is it possible display '育儿' in the URL link directly? Will it be good for SEO? 回答1: The text displayed in IE's address bar is the URL encoded form of the hex version of those characters. The hex version of '育儿' encoded in UTF-8 is

%20 is added instead of spaces

做~自己de王妃 提交于 2019-12-23 15:33:32
问题 I guess this is small issue but yet i had to ask here since i am running short in my project. When I pass string to the function in another controller, it changes spaces into %20 sign. I guess the controller thinks the string passed as url and encodes it. But I don't know exactly how to remove it or if possible do not let it to change spaces into %20. Here is the code which i use; $message="The user name you provided is already in our database"; redirect('admin/add_user/'.$message); Here is

Does Windows have any built-in utility to encode/decode URL?

ぐ巨炮叔叔 提交于 2019-12-23 10:07:31
问题 The certutil utiliiy in Windows can be used to perform Base64 encoding and deocding. Is there any built-in utility for URL encoding and decoding? There are many free tools available on web. But I am specifically looking for Windows built-in utility or if not simple script that can run on Windows. Thanks! 回答1: Base64 VBA Base64 encoding and decoding can be done with VBA. You can copy/paste this code and put it in Excel VBA, for example, and then use it's methods to encode and decode Base64.

javascript - encodeUriComponent with exclamation mark?

谁说我不能喝 提交于 2019-12-23 09:10:11
问题 Native encodeURIComponent doesn't support encoding exclamation mark - ! which I need to have in url's query param encoded properly.. node.js querystring.stringify() doesn't it as well.. is the only way to use custom function like - https://github.com/kvz/phpjs/blob/master/functions/url/urlencode.js#L30 ? 回答1: You could re-define the native function to add that functionality. Here's an example of extending encodeURIComponent to handle exclamation marks. // adds '!' to encodeURIComponent