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
- WebService.cs
- QueryStringParameter.cs
- CodeParameterDeclarationExpressionCollection.cs
- RemotingClientProxy.cs
- ExcCanonicalXml.cs
- ImageField.cs
- unsafenativemethodstextservices.cs
- ParentUndoUnit.cs
- ArglessEventHandlerProxy.cs
- FormatException.cs
- DataServiceQueryOfT.cs
- HtmlInputCheckBox.cs
- VarRemapper.cs
- DetailsViewUpdateEventArgs.cs
- XmlIncludeAttribute.cs
- AssemblyBuilder.cs
- HijriCalendar.cs
- ProcessModelSection.cs
- TextSpanModifier.cs
- ConnectionStringsExpressionBuilder.cs
- loginstatus.cs
- KeyNotFoundException.cs
- AssociatedControlConverter.cs
- TcpProcessProtocolHandler.cs
- AttachedPropertyInfo.cs
- PreloadedPackages.cs
- Clause.cs
- FileDialogCustomPlacesCollection.cs
- DbParameterCollection.cs
- MessagePropertyDescription.cs
- DataGridTextBoxColumn.cs
- EdmSchemaError.cs
- DataViewSetting.cs
- Stylus.cs
- ToolBarTray.cs
- UserControlDocumentDesigner.cs
- UInt32Storage.cs
- DataGridViewTopLeftHeaderCell.cs
- NetCodeGroup.cs
- BuildManagerHost.cs
- ActivityExecutionContext.cs
- SchemaImporterExtension.cs
- Baml2006ReaderSettings.cs
- Literal.cs
- TableHeaderCell.cs
- BrowserDefinition.cs
- HandlerFactoryWrapper.cs
- CodeDOMProvider.cs
- EventLogPermissionAttribute.cs
- TextEmbeddedObject.cs
- Normalization.cs
- KnownTypesProvider.cs
- TextDecorationCollection.cs
- ProfessionalColors.cs
- CodeIdentifier.cs
- ShellProvider.cs
- WindowsGrip.cs
- CombinedGeometry.cs
- ListenerConnectionDemuxer.cs
- AppSettingsExpressionEditor.cs
- ItemChangedEventArgs.cs
- SqlDependency.cs
- WebBrowserHelper.cs
- CompressedStack.cs
- ElementHost.cs
- TraceListeners.cs
- TypeContext.cs
- PointAnimation.cs
- VectorAnimationUsingKeyFrames.cs
- MetaType.cs
- GeneralTransform3D.cs
- PlainXmlWriter.cs
- EditCommandColumn.cs
- XPathSelectionIterator.cs
- StorageEntityContainerMapping.cs
- Error.cs
- ListDictionaryInternal.cs
- CodeIndexerExpression.cs
- XNodeNavigator.cs
- PathGeometry.cs
- InputGestureCollection.cs
- QueueProcessor.cs
- Stack.cs
- ComponentResourceKeyConverter.cs
- WebPartConnectionCollection.cs
- XPathPatternBuilder.cs
- XmlSortKeyAccumulator.cs
- PriorityQueue.cs
- ControlEvent.cs
- FlowDocumentPage.cs
- BrowserCapabilitiesCompiler.cs
- XmlProcessingInstruction.cs
- CodeComment.cs
- UIElement.cs
- DiscoveryClient.cs
- ScriptControlDescriptor.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- XmlStringTable.cs
- ZipIORawDataFileBlock.cs
- SvcMapFile.cs