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
- TdsRecordBufferSetter.cs
- HttpRuntime.cs
- _LocalDataStore.cs
- PasswordDeriveBytes.cs
- FunctionQuery.cs
- HttpApplication.cs
- TextBoxBase.cs
- BaseResourcesBuildProvider.cs
- ToolStripContainerActionList.cs
- FolderLevelBuildProviderCollection.cs
- DetailsViewPageEventArgs.cs
- WriteableBitmap.cs
- ZipIOExtraField.cs
- ProxyHwnd.cs
- BrowserCapabilitiesCompiler.cs
- PipelineDeploymentState.cs
- WebServicesSection.cs
- ListSortDescription.cs
- SortedList.cs
- DataGridViewColumnConverter.cs
- SystemWebCachingSectionGroup.cs
- Canvas.cs
- Base64Stream.cs
- ReflectionServiceProvider.cs
- NamespaceList.cs
- AliasedExpr.cs
- Propagator.cs
- LineBreakRecord.cs
- PolyQuadraticBezierSegment.cs
- AmbientLight.cs
- SubqueryTrackingVisitor.cs
- DataGridColumnReorderingEventArgs.cs
- DefaultClaimSet.cs
- KeyPressEvent.cs
- Size3DConverter.cs
- TypeSystem.cs
- DummyDataSource.cs
- PropertyConverter.cs
- RowToParametersTransformer.cs
- SchemaNotation.cs
- ListBoxAutomationPeer.cs
- StrongNameUtility.cs
- UIPropertyMetadata.cs
- UnsafeNativeMethods.cs
- Privilege.cs
- PersistenceProviderBehavior.cs
- MsmqIntegrationChannelListener.cs
- PackageRelationshipSelector.cs
- DataReceivedEventArgs.cs
- RegexCompilationInfo.cs
- XmlCountingReader.cs
- InplaceBitmapMetadataWriter.cs
- Atom10FormatterFactory.cs
- ListViewTableCell.cs
- RecognitionResult.cs
- CollectionViewGroupInternal.cs
- LOSFormatter.cs
- _TLSstream.cs
- WindowsGraphics2.cs
- CodeBinaryOperatorExpression.cs
- input.cs
- UpdateTranslator.cs
- SrgsElementFactory.cs
- SerializationFieldInfo.cs
- RuleAttributes.cs
- FrameworkElementFactoryMarkupObject.cs
- DashStyle.cs
- ChildDocumentBlock.cs
- RequestCachePolicyConverter.cs
- Run.cs
- DefaultSerializationProviderAttribute.cs
- ChannelServices.cs
- ConfigXmlWhitespace.cs
- NonDualMessageSecurityOverHttp.cs
- WmpBitmapEncoder.cs
- SQLRoleProvider.cs
- JumpTask.cs
- DataPager.cs
- _ConnectionGroup.cs
- XmlImplementation.cs
- Encoder.cs
- BuildManager.cs
- MenuAdapter.cs
- PropertyGeneratedEventArgs.cs
- SimpleMailWebEventProvider.cs
- DocumentViewerBase.cs
- OdbcDataReader.cs
- FixedDocumentPaginator.cs
- StorageRoot.cs
- ConnectionProviderAttribute.cs
- QilGeneratorEnv.cs
- ClrProviderManifest.cs
- ApplicationHost.cs
- Task.cs
- BitmapCacheBrush.cs
- compensatingcollection.cs
- WindowsProgressbar.cs
- Timer.cs
- ServiceConfigurationTraceRecord.cs
- XmlSchemaProviderAttribute.cs