using System; using System.Reflection; using System.Runtime.InteropServices; using System.Text; namespace PACNET { /// public delegate int PAC_CALLBACK_FUNC(); internal class StrConvert { internal static byte[] AnsiString([In] string str) { Encoding ascii = Encoding.ASCII; Encoding unicode = Encoding.Unicode; byte[] unicodeBytes = unicode.GetBytes(str); byte[] temp = Encoding.Convert(unicode, ascii, unicodeBytes); byte[] ret = new byte[temp.Length + 1]; temp.CopyTo(ret, 0); return ret; } internal static int StringofByte_Len(byte[] bytes) { int len = 0; for (int i = 0; i < bytes.Length; i++) { if (bytes[i] != 0) { len++; } else break; } return len; } internal static string WideString(byte[] CharStr) { return Encoding.Default.GetString(CharStr, 0, StringofByte_Len(CharStr)); } } }