本文整理汇总了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);
}
}
示例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);
}
示例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 );
}
示例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 );
}
示例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;
}
}