using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Yaulw.Tools
{
///
/// Common Conversion Operations
///
public static class Convert
{
///
/// Convert a a String to a UTF Byte Array
///
/// string to convert
/// a Byte Array from a String
public static byte[] StrToByteArrayUTF(string str)
{
if (!String.IsNullOrEmpty(str))
{
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
return encoding.GetBytes(str);
}
return null;
}
///
/// Convert a a String to an ASCII Byte Array
///
/// string to convert
/// a Byte Array from a String
public static byte[] StrToByteArrayAscii(string str)
{
if (!String.IsNullOrEmpty(str))
{
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
return null;
}
}
}