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


C# System.Text.ASCIIEncoding.GetDecoder方法代码示例

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


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

示例1: Base64Decode

        private static string Base64Decode(string data)
        {
            try
            {
                System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding();
                System.Text.Decoder utf8Decode = encoder.GetDecoder();

                byte[] todecode_byte = Convert.FromBase64String(data);
                int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
                char[] decoded_char = new char[charCount];
                utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
                string result = new String(decoded_char);
                return result;
            }
            catch(Exception e)
            {
                throw new Exception("Error in base64Decode" + e.Message);
            }
        }
开发者ID:greenprince,项目名称:nexpose-sharp,代码行数:19,代码来源:Main.cs

示例2: GetTypeface

        public string GetTypeface()
        {
            char[] charBuf = new char[16];

            System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding();
            System.Text.Decoder d = ae.GetDecoder();

            d.GetChars(Typeface, 0, 16, charBuf, 0);

            return new string(charBuf);
        }
开发者ID:bitforks,项目名称:Font-Validator,代码行数:11,代码来源:Table_PCLT.cs

示例3: getFileName

            public string getFileName()
            {
                char [] charBuf = new char[6];

                System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding();
                System.Text.Decoder d = ae.GetDecoder();

                d.GetChars( m_FileName, 0, 6, charBuf, 0 );

                return new string( charBuf );
            }
开发者ID:bitforks,项目名称:Font-Validator,代码行数:11,代码来源:Table_PCLT.cs

示例4: getCharacterComplement

            public string getCharacterComplement()
            {
                char [] charBuf = new char[8];

                System.Text.ASCIIEncoding ae = new System.Text.ASCIIEncoding();
                System.Text.Decoder d = ae.GetDecoder();

                d.GetChars( m_CharacterComplement, 0, 8, charBuf, 0 );

                return new string( charBuf );
            }
开发者ID:bitforks,项目名称:Font-Validator,代码行数:11,代码来源:Table_PCLT.cs

示例5: Serialize

		/// <summary>
		/// Returns the NML representation of the given GraphAbstract
		/// </summary>	
		/// <returns></returns>
		public string Serialize()
		{
			try
			{
				GraphAbstract g = this.site.Abstract;
				System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();

				MemoryStream stream = new MemoryStream();
				XmlTextWriter writer = new XmlTextWriter(stream, System.Text.ASCIIEncoding.ASCII);
				writer.Formatting = System.Xml.Formatting.Indented;
				this.Serialize(writer,g);

				
				//StringReader reader = new StringReader();
				int count = 0;
				stream.Seek(0, SeekOrigin.Begin);

				byte[] byteArray = new byte[stream.Length];

				while(count < stream.Length)
				{
					byteArray[count++] = Convert.ToByte(stream.ReadByte());
				}

				// Decode the byte array into a char array 
				// and write it to the console.
				char[] charArray = new char[asciiEncoding.GetCharCount(byteArray, 0, count)];
				asciiEncoding.GetDecoder().GetChars(byteArray, 0, count, charArray, 0);

				string s = new string(charArray);
				
				
				writer.Close();

				stream.Close();
				return s;
			}
			catch(Exception exc)
			{
				Trace.WriteLine(exc.Message,"NMLSerializer.Serialize");
				return string.Empty;
			}
		}
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:47,代码来源:NMLSerializer.cs


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