I am writing a web application that requires friendly URLs, but I'm not sure how to handle non-7-bit ASCII characters. I do not want to replace characters with emphasis on URL encoded objects. Is there a C # method that allows such a conversion, or do I need to actually display every single case that I want to handle?
I donโt know how to do this in C #, but the magic words you want are "Unicode decomposition." There's a standard way to break up composed characters such as "รฉ", and then you just need to filter out non-ASCII files.
Edit: this may be what you are looking for.
Use UTF-8:
Non-ASCII characters must first be encoded in accordance with UTF-8 [STD63], and then each octet of the corresponding UTF-8 sequence must be percentage encoded to represent URI characters. - RFC 3986
- : URL-: URL-
, . . .
: http://www.codeproject.com/KB/cs/UnicodeNormalization.aspx
private string LatinToAscii(string InString) { string newString = string.Empty, charString; char ch; int charsCopied; for (int i = 0; i < InString.Length; i++) { charString = InString.Substring(i, 1); charString = charString.Normalize(NormalizationForm.FormKD); // If the character doesn't decompose, leave it as-is if (charString.Length == 1) newString += charString; else { charsCopied = 0; for (int j = 0; j < charString.Length; j++) { ch = charString[j]; // If the char is 7-bit ASCII, add if (ch < 128) { newString += ch; charsCopied++; } } /* If we've decomposed non-ASCII, give it back * in its entirety, since we only mean to decompose * Latin chars. */ if (charsCopied == 0) newString += InString.Substring(i, 1); } } return newString; }
- . . , . , , , , querystring, ? .
/ , , querystring. , - - , .. , , , . 2005 , , , id querystring. , . , , , . , - AJAX, .
- , - , , - , , .
, , , , Replace() string.
http://Montrรฉal.com
(/ , ?)
Source: https://habr.com/ru/post/1704224/More articles:Convert Email Address From X400 to SMTP - vb.netHow to find html elements containing specific text in an html comment? - jqueryHow to extract sheet nodes from Oracle XMLTYPE - oracleJava floating point - (conversion for feet / meters) - javaWhat is the correct expression used to format dates from "yyyyMMdd" to "M / d / yyyy" in SQL Server Reporting Services? - sql-serverHow to delete the last line of a text file using the command line? - cmdRequest access to MS using multiple tables - sqlActionScript - What is this programming language? - actionscriptHow to set the text on the "Save" button in the Windows file dialog box? - winapiMousewheel needs to scroll user control - user-interfaceAll Articles