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
- SaveFileDialog.cs
- TextStore.cs
- HttpRequest.cs
- ScanQueryOperator.cs
- Misc.cs
- WindowsRegion.cs
- HtmlSelect.cs
- ContentOperations.cs
- EventBuilder.cs
- ResourceWriter.cs
- NameHandler.cs
- LocationUpdates.cs
- XmlSchemaSimpleTypeUnion.cs
- PersonalizationDictionary.cs
- HelpProvider.cs
- NetworkInformationException.cs
- CreateUserErrorEventArgs.cs
- DataGridViewLinkCell.cs
- TypeDependencyAttribute.cs
- ContentIterators.cs
- AnchorEditor.cs
- CharacterMetrics.cs
- WebPartEventArgs.cs
- WindowsSlider.cs
- DynamicRendererThreadManager.cs
- BindingCompleteEventArgs.cs
- GroupBox.cs
- basecomparevalidator.cs
- XmlMtomWriter.cs
- ToolStripProgressBar.cs
- UndoManager.cs
- WebHttpBehavior.cs
- SHA1Managed.cs
- NamespaceInfo.cs
- CodeExpressionStatement.cs
- DiscoveryExceptionDictionary.cs
- CodeDOMProvider.cs
- InternalConfigHost.cs
- LicenseProviderAttribute.cs
- InvalidateEvent.cs
- Page.cs
- BlockExpression.cs
- Span.cs
- ValidationPropertyAttribute.cs
- TrustSection.cs
- GorillaCodec.cs
- Nullable.cs
- UserControl.cs
- BoolLiteral.cs
- RemotingServices.cs
- ScrollItemPatternIdentifiers.cs
- ValidationRuleCollection.cs
- clipboard.cs
- SafeNativeMethods.cs
- FontClient.cs
- SmiTypedGetterSetter.cs
- TextStore.cs
- RayMeshGeometry3DHitTestResult.cs
- QuaternionRotation3D.cs
- ToolStripDropDownMenu.cs
- ToolStripSettings.cs
- NonParentingControl.cs
- DataGridViewCellCollection.cs
- DataListItemEventArgs.cs
- TdsParameterSetter.cs
- LoadWorkflowAsyncResult.cs
- FilteredXmlReader.cs
- BoundingRectTracker.cs
- TextEditorCopyPaste.cs
- Light.cs
- UidManager.cs
- RuntimeHelpers.cs
- ClientTargetSection.cs
- ClientSettingsStore.cs
- CommandEventArgs.cs
- WebPartDisplayModeCancelEventArgs.cs
- ModifierKeysConverter.cs
- PropertyGeneratedEventArgs.cs
- Queue.cs
- X509SubjectKeyIdentifierClause.cs
- MetadataPropertyCollection.cs
- XmlNodeReader.cs
- ConfigXmlElement.cs
- TileBrush.cs
- XmlObjectSerializer.cs
- SrgsGrammarCompiler.cs
- CheckBoxRenderer.cs
- UIElementAutomationPeer.cs
- NavigationEventArgs.cs
- CreateUserWizard.cs
- SelectionProviderWrapper.cs
- AssemblyLoader.cs
- AttributeXamlType.cs
- ProfileServiceManager.cs
- DataGridTextBoxColumn.cs
- CodeDelegateInvokeExpression.cs
- DBDataPermissionAttribute.cs
- SimpleWorkerRequest.cs
- Floater.cs
- XXXInfos.cs