Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Util / HttpEncoderUtility.cs / 1305376 / HttpEncoderUtility.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * Helper class for common encoding routines * * Copyright (c) 2009 Microsoft Corporation */ namespace System.Web.Util { using System; using System.Web; internal static class HttpEncoderUtility { public static int HexToInt(char h) { return (h >= '0' && h <= '9') ? h - '0' : (h >= 'a' && h <= 'f') ? h - 'a' + 10 : (h >= 'A' && h <= 'F') ? h - 'A' + 10 : -1; } public static char IntToHex(int n) { Debug.Assert(n < 0x10); if (n <= 9) return (char)(n + (int)'0'); else return (char)(n - 10 + (int)'a'); } // Set of safe chars, from RFC 1738.4 minus '+' public static bool IsUrlSafeChar(char ch) { if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9') return true; switch (ch) { case '-': case '_': case '.': case '!': case '*': case '(': case ')': return true; } return false; } // Helper to encode spaces only internal static String UrlEncodeSpaces(string str) { if (str != null && str.IndexOf(' ') >= 0) str = str.Replace(" ", "%20"); return str; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * Helper class for common encoding routines * * Copyright (c) 2009 Microsoft Corporation */ namespace System.Web.Util { using System; using System.Web; internal static class HttpEncoderUtility { public static int HexToInt(char h) { return (h >= '0' && h <= '9') ? h - '0' : (h >= 'a' && h <= 'f') ? h - 'a' + 10 : (h >= 'A' && h <= 'F') ? h - 'A' + 10 : -1; } public static char IntToHex(int n) { Debug.Assert(n < 0x10); if (n <= 9) return (char)(n + (int)'0'); else return (char)(n - 10 + (int)'a'); } // Set of safe chars, from RFC 1738.4 minus '+' public static bool IsUrlSafeChar(char ch) { if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9') return true; switch (ch) { case '-': case '_': case '.': case '!': case '*': case '(': case ')': return true; } return false; } // Helper to encode spaces only internal static String UrlEncodeSpaces(string str) { if (str != null && str.IndexOf(' ') >= 0) str = str.Replace(" ", "%20"); return str; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlBoundElement.cs
- validation.cs
- StateBag.cs
- XPathDocumentBuilder.cs
- ScriptReferenceEventArgs.cs
- PolicyLevel.cs
- ObjectAnimationBase.cs
- VBCodeProvider.cs
- BindingMemberInfo.cs
- SettingsPropertyValueCollection.cs
- EncodingDataItem.cs
- MatrixValueSerializer.cs
- TextRunCache.cs
- DataServiceKeyAttribute.cs
- Size3D.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- ToolStripItem.cs
- CLRBindingWorker.cs
- OperationResponse.cs
- FunctionOverloadResolver.cs
- ThaiBuddhistCalendar.cs
- PropertyRef.cs
- Configuration.cs
- CodePrimitiveExpression.cs
- BitmapSizeOptions.cs
- FrameworkContentElementAutomationPeer.cs
- ListViewSortEventArgs.cs
- PtsHelper.cs
- AttachInfo.cs
- RightsManagementEncryptedStream.cs
- EventHandlersStore.cs
- MaskedTextBoxTextEditor.cs
- ClrProviderManifest.cs
- SR.cs
- CharacterString.cs
- PartEditor.cs
- UDPClient.cs
- ToolStripItemClickedEventArgs.cs
- CodeSnippetExpression.cs
- XmlTextEncoder.cs
- MutexSecurity.cs
- TreeChangeInfo.cs
- SoapElementAttribute.cs
- ProofTokenCryptoHandle.cs
- WebContext.cs
- FilterUserControlBase.cs
- ModelItemExtensions.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- LinkButton.cs
- GridItem.cs
- WindowsToolbarAsMenu.cs
- TCPListener.cs
- DiagnosticTraceSource.cs
- StyleXamlParser.cs
- VirtualPathUtility.cs
- DataSourceCacheDurationConverter.cs
- MaskedTextBoxTextEditor.cs
- XmlDocumentSchema.cs
- CommonProperties.cs
- XmlnsDefinitionAttribute.cs
- XmlAttributeProperties.cs
- GridErrorDlg.cs
- ScaleTransform3D.cs
- relpropertyhelper.cs
- NextPreviousPagerField.cs
- odbcmetadatacolumnnames.cs
- DockProviderWrapper.cs
- XmlHierarchyData.cs
- XmlAttributeCollection.cs
- CodeExporter.cs
- TabItemWrapperAutomationPeer.cs
- SchemeSettingElement.cs
- CompensatableTransactionScopeActivity.cs
- DeflateStream.cs
- NullRuntimeConfig.cs
- XmlSignatureManifest.cs
- ElementMarkupObject.cs
- CodeMemberEvent.cs
- SortedDictionary.cs
- MenuItem.cs
- ApplicationFileParser.cs
- FloatSumAggregationOperator.cs
- RequestQueryProcessor.cs
- AssemblyNameProxy.cs
- ByteStack.cs
- CapabilitiesState.cs
- HtmlForm.cs
- DbConnectionStringBuilder.cs
- OutputCacheProfileCollection.cs
- CriticalExceptions.cs
- FactoryId.cs
- RemoteX509Token.cs
- ToolStripHighContrastRenderer.cs
- XmlWrappingReader.cs
- ImageSourceValueSerializer.cs
- XmlBoundElement.cs
- FamilyTypefaceCollection.cs
- TreeBuilderBamlTranslator.cs
- PassportAuthentication.cs
- ObjectItemCollection.cs