Source/NFX/MiscUtils.cs
/// <summary>
/// Performs URI.EscapeDataString with additional replacement of " and ' chars with their hex equivalents.
/// This method is suitable for escaping client-side intelligent keys that may have single/double quotes
/// </summary>
Performs URI.EscapeDataString with additional replacement of " and ' chars with their hex equivalents.
This method is suitable for escaping client-side intelligent keys that may have single/double quotes
Performs URI . EscapeDataString with additional replacement of " and ' chars with their hex equivalents . This method is suitable for escaping client - side intelligent keys that may have single / double quotes
public static string EscapeURIDataStringWithQuotes(this string uri)
    {
      const string SQ = "%27";
      const string DQ = "%22";
      if (uri.IsNullOrWhiteSpace()) return string.Empty;
      var ds = Uri.EscapeDataString(uri);
      var result = new StringBuilder();
      for(var i=0; i<ds.Length; i++)
      {
        var c = ds[i];
        if (c=='\'') result.Append(SQ);
        else
        if (c=='"') result.Append(DQ);
        else
         result.Append(c);
      }
      return result.ToString();
    }
public static string EscapeURIDataStringWithQuotes ( this string uri ) { const string SQ = " " ; const string DQ = " " ; if ( uri . IsNullOrWhiteSpace ( ) ) return string . Empty ; var ds = Uri . EscapeDataString ( uri ) ; var result = new StringBuilder ( ) ; for ( var i = 0 ; i < ds . Length ; i ++ ) { var c = ds [ i ] ; if ( c == ' \' ' ) result . Append ( SQ ) ; else if ( c == ' ' ) result . Append ( DQ ) ; else result . Append ( c ) ; } return result . ToString ( ) ; }
Performs URI.EscapeDataString with additional replacement of " and ' chars with their hex equivalents.
Performs URI . EscapeDataString with additional replacement of " and ' chars with their hex equivalents .
string
this