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
- WrappedKeySecurityTokenParameters.cs
- EntityDesignerUtils.cs
- And.cs
- ObjectCache.cs
- ContentFileHelper.cs
- TemplateControlCodeDomTreeGenerator.cs
- XamlTypeMapper.cs
- BitmapEffectDrawingContextWalker.cs
- RectConverter.cs
- SecurityElement.cs
- GrammarBuilderRuleRef.cs
- HwndMouseInputProvider.cs
- EmptyReadOnlyDictionaryInternal.cs
- ProbeDuplexCD1AsyncResult.cs
- Size.cs
- ServiceConfigurationTraceRecord.cs
- DeviceContext2.cs
- XmlILConstructAnalyzer.cs
- DefaultProxySection.cs
- Duration.cs
- MenuRendererStandards.cs
- ProxyWebPartManagerDesigner.cs
- WsdlParser.cs
- Decoder.cs
- SrgsOneOf.cs
- ScopeElementCollection.cs
- WebPartAddingEventArgs.cs
- SmiTypedGetterSetter.cs
- TextHintingModeValidation.cs
- BinaryMethodMessage.cs
- FileUtil.cs
- OdbcConnectionString.cs
- Brush.cs
- Console.cs
- OrthographicCamera.cs
- CompilerParameters.cs
- OrderByQueryOptionExpression.cs
- ListenerServiceInstallComponent.cs
- PeerNearMe.cs
- FileChangesMonitor.cs
- DataGridViewColumnEventArgs.cs
- TextRangeBase.cs
- LinqDataSourceDeleteEventArgs.cs
- XmlWellformedWriter.cs
- SpecularMaterial.cs
- SelectionPatternIdentifiers.cs
- ToolStripItem.cs
- StringAnimationUsingKeyFrames.cs
- ScriptingScriptResourceHandlerSection.cs
- SqlGatherProducedAliases.cs
- ProcessModelInfo.cs
- RestHandler.cs
- SQLInt16Storage.cs
- COM2ColorConverter.cs
- CodeRemoveEventStatement.cs
- ResXBuildProvider.cs
- BuildProviderInstallComponent.cs
- ECDsa.cs
- ResourceAssociationSetEnd.cs
- followingquery.cs
- ListBoxItemAutomationPeer.cs
- LineSegment.cs
- WindowsListViewGroup.cs
- DoubleAnimationClockResource.cs
- SymLanguageType.cs
- PtsHelper.cs
- DeferredTextReference.cs
- TreeViewCancelEvent.cs
- CheckBoxRenderer.cs
- XMLDiffLoader.cs
- glyphs.cs
- GeometryCombineModeValidation.cs
- ItemChangedEventArgs.cs
- PropertyGridView.cs
- CfgSemanticTag.cs
- DataSourceComponent.cs
- TraceSection.cs
- StaticContext.cs
- DBDataPermissionAttribute.cs
- Wizard.cs
- SqlDataSourceEnumerator.cs
- PropertyDescriptorGridEntry.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- AutomationElement.cs
- EntityProviderFactory.cs
- SQLMoney.cs
- PersonalizationProviderCollection.cs
- EntityReference.cs
- LowerCaseStringConverter.cs
- SoapServerProtocol.cs
- AuthorizationContext.cs
- DataGridLinkButton.cs
- SqlDataSource.cs
- ClientSideQueueItem.cs
- NativeDirectoryServicesQueryAPIs.cs
- BinaryCommonClasses.cs
- InkCollectionBehavior.cs
- WeakRefEnumerator.cs
- WebPartsPersonalization.cs
- ObjRef.cs