当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.MemoryStream.reset方法代码示例

本文整理汇总了C#中System.IO.MemoryStream.reset方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.MemoryStream.reset方法的具体用法?C# System.IO.MemoryStream.reset怎么用?C# System.IO.MemoryStream.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.MemoryStream的用法示例。


在下文中一共展示了System.IO.MemoryStream.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: encode

		public static System.String encode(System.String s, System.String enc)
		{
			if (!needsEncoding(s))
			{
				return s;
			}
			
			int length = s.Length;
			
			System.Text.StringBuilder out_Renamed = new System.Text.StringBuilder(length);
			
			System.IO.MemoryStream buf = new System.IO.MemoryStream(10); // why 10? w3c says so.
			
			//UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
			//UPGRADE_TODO: Constructor 'java.io.OutputStreamWriter.OutputStreamWriter' was converted to 'System.IO.StreamWriter.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioOutputStreamWriterOutputStreamWriter_javaioOutputStream_javalangString'"
			System.IO.StreamWriter writer = new System.IO.StreamWriter(new System.IO.StreamWriter(buf, System.Text.Encoding.GetEncoding(enc)).BaseStream, new System.IO.StreamWriter(buf, System.Text.Encoding.GetEncoding(enc)).Encoding);
			
			for (int i = 0; i < length; i++)
			{
				int c = (int) s[i];
				if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == ' ')
				{
					if (c == ' ')
					{
						c = '+';
					}
					
					toHex(out_Renamed, SupportClass.ToSByteArray(buf.ToArray()));
					//UPGRADE_ISSUE: Method 'java.io.ByteArrayOutputStream.reset' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioByteArrayOutputStreamreset'"
					buf.reset();
					
					out_Renamed.Append((char) c);
				}
				else
				{
					try
					{
						writer.Write((System.Char) c);
						
						if (c >= 0xD800 && c <= 0xDBFF && i < length - 1)
						{
							int d = (int) s[i + 1];
							if (d >= 0xDC00 && d <= 0xDFFF)
							{
								writer.Write((System.Char) d);
								i++;
							}
						}
						
						writer.Flush();
					}
					catch (System.IO.IOException ex)
					{
						throw new System.ArgumentException(s);
					}
				}
			}
			
			toHex(out_Renamed, SupportClass.ToSByteArray(buf.ToArray()));
			
			return out_Renamed.ToString();
		}
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:62,代码来源:URLEncoder.cs


注:本文中的System.IO.MemoryStream.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。