本文整理汇总了C#中System.Text.UTF8Encoding.GetDecoder方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.UTF8Encoding.GetDecoder方法的具体用法?C# System.Text.UTF8Encoding.GetDecoder怎么用?C# System.Text.UTF8Encoding.GetDecoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.UTF8Encoding
的用法示例。
在下文中一共展示了System.Text.UTF8Encoding.GetDecoder方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Base64Decode
/// <summary>
/// Base64解密
/// </summary>
/// <param name="Message">需要解密的字符串</param>
/// <returns></returns>
public string Base64Decode(string Message)
{
try
{
string result = "";
if (isEncrypt)
{
Message = Message.Replace(" ", "+");
string gbStr = System.Text.Encoding.GetEncoding("utf-8").GetString(System.Text.Encoding.Default.GetBytes(Message));
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(Message);
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);
result = new String(decoded_char);
}
else
{
result = Message;
}
return result;
}
catch (Exception e)
{
throw new Exception("Error in base64Decode" + e.Message);
}
}
示例2: DecodeFrom64
//this function Convert to Decord your Password
public static string DecodeFrom64(string encodedData)
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(encodedData);
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;
}
示例3: Base64Decode
/// Base64解密
public static string Base64Decode(string Message)
{
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(Message);
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);
}
}
示例4: Decode
public static string Decode(byte[] data)
{
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
int charCount = utf8Decode.GetCharCount(data, 0, data.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(data, 0, data.Length, decoded_char, 0);
string result = new String(decoded_char);
return result;
}
catch (Exception e)
{
throw new Exception("Error decoding base64 data: " + e.Message);
}
}
示例5: Base64Decode
/// <summary>
/// Decode a Base64 encoded string.
/// </summary>
public string Base64Decode(string data)
{
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] bytToDecode = Convert.FromBase64String(data);
int charCount = utf8Decode.GetCharCount(bytToDecode, 0, bytToDecode.Length);
char[] chrDecoded = new char[charCount];
utf8Decode.GetChars(bytToDecode, 0, bytToDecode.Length, chrDecoded, 0);
string strResult = new String(chrDecoded);
return strResult;
}
catch (Exception e)
{
throw new Exception("Error in Base64Decode" + e.Message);
}
}
示例6: llBase64ToString
public string llBase64ToString(IScriptInstance script, string str)
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
string result = String.Empty;
try
{
byte[] todecode_byte = Convert.FromBase64String(str);
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);
result = new String(decoded_char);
}
catch (Exception e)
{
throw new Exception("Error in base64Decode" + e.Message);
}
return result;
}
示例7: SaveTestGroupNodeToXmlElement
/// <summary>
/// Creates the XmlElement for the third level, or TestGroup level of the
/// tree.
/// </summary>
/// <param name="doc">
/// The XmlDocument object that will eventually contain this Element.
/// </param>
/// <param name="node">
/// The TreeNode representation of this TestGroup
/// </param>
/// <returns>
/// The XmlElement that contains the TestGroup and all its children.
/// </returns>
private System.Xml.XmlElement SaveTestGroupNodeToXmlElement(
System.Xml.XmlDocument doc,
TreeNode node)
{
System.Xml.XmlElement ret = doc.CreateElement("TestGroup");
IUPnPTestGroup group = node.Tag as IUPnPTestGroup;
if (group != null)
{
ret.SetAttribute("name", group.GroupName);
ret.SetAttribute("state", Util.UPnPTestStatesToString(group.GroupState));
ret.SetAttribute("description", group.Description);
for (int i = 0; i < group.TestNames.GetLength(0); i++)
{
string result = "";
if (group.Result.GetLength(0) > i)
{
result = group.Result[i];
}
System.Xml.XmlElement testElement =
SaveTestToXmlElement(
doc,
group.TestNames[i],
Util.UPnPTestStatesToString(group.TestStates[i]),
group.TestDescription[i],
result,
group.Log);
ret.AppendChild(testElement);
}
// output the packets. I wish that there were a way to
// associate this with the individual tests, but it doesn't
// appear to be possible with the current data structures.
foreach (HTTPMessage httpMesg in group.PacketTrace)
{
byte[] packetBytes = httpMesg.RawPacket;
System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Dec = utf8.GetDecoder();
int len = packetBytes.Length;
char[] packetChars = new char[len];
utf8Dec.GetChars(packetBytes, 0, len, packetChars, 0);
string packetString = new String(packetChars);
System.Xml.XmlElement packetElement =
doc.CreateElement("Packet");
packetElement.InnerText = packetString;
ret.AppendChild(packetElement);
}
}
return ret;
}
示例8: Base64Decode
public static string Base64Decode(string sData)
{
var encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecodeByte = Convert.FromBase64String(sData);
int charCount = utf8Decode.GetCharCount(todecodeByte, 0, todecodeByte.Length);
var decodedChar = new char[charCount];
utf8Decode.GetChars(todecodeByte, 0, todecodeByte.Length, decodedChar, 0);
var result = new String(decodedChar); return result;
}
示例9: Base64Decode
private string Base64Decode(string encodedData) {
var encoder = new System.Text.UTF8Encoding();
var utf8Decode = encoder.GetDecoder();
byte[] todecodeByte = Convert.FromBase64String(encodedData);
int charCount = utf8Decode.GetCharCount(todecodeByte, 0, todecodeByte.Length);
char[] decodedChar = new char[charCount];
utf8Decode.GetChars(todecodeByte, 0, todecodeByte.Length, decodedChar, 0);
return new String(decodedChar);
}
示例10: base64Decode
/// <summary>
/// Decodes a base64 string into a readable string
/// </summary>
/// <param name="data">Data to decode</param>
/// <returns></returns>
private string base64Decode(string data)
{
//add padding with '=' to string to accommodate C# Base64 requirements
int strlen = data.Length + (4 - (data.Length % 4));
char pad = '=';
string datapad;
if (strlen == (data.Length + 4))
{
datapad = data;
}
else
{
datapad = data.PadRight(strlen, pad);
}
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
// create byte array to store Base64 string
byte[] todecode_byte = Convert.FromBase64String(datapad);
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);
}
}