System.Yaml.UriEncoding.Escape C# (CSharp) Méthode

Escape() public static méthode

public static Escape ( string s ) : string
s string
Résultat string
        public static string Escape(string s)
        {
            return NonUriChar.Replace(s, m => {
                var c = m.Value[0];
                return ( c == ' ' ) ? "+" :
                       ( c < 0x80 ) ? IntToHex(c) :
                       ( c < 0x0800 ) ? IntToHex(( ( c >> 6 ) & 0x1f ) + 0xc0, ( c & 0x3f ) + 0x80) :
                       IntToHex(( ( c >> 12 ) & 0x0f ) + 0xe0, ( ( c >> 6 ) & 0x3f ) + 0x80, ( c & 0x3f ) + 0x80);
            }
            );
        }

Usage Example

Exemple #1
0
 /// <summary>
 /// Escape the string in URI encoding format.
 /// </summary>
 /// <param name="s">String to be escaped.</param>
 /// <returns>Escaped string.</returns>
 public static string UriEscape(this string s)
 {
     return(UriEncoding.Escape(s));
 }