@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The MultiByteToWideChar API !!!!C# Signature: [DllImport("kernel32.dll")] static extern int MultiByteToWideChar(uint CodePage, uint dwFlags, string lpMultiByteStr, int cbMultiByte, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpWideCharStr, int cchWideChar); Alternative version [DllImport("kernel32.dll")] private static extern int MultiByteToWideChar( uint CodePage, uint dwFlags, [MarshalAs(UnmanagedType.LPArray)] Byte[] lpMultiByteStr, int cbMultiByte, [Out, MarshalAs(UnmanagedType.LPArray)] Byte[] lpWideCharStr, int cchWideChar); !!!!User-Defined Types: None. !!!!Notes: None. !!!!Tips & Tricks: Please add some! !!!!Sample Code: public class Multibyte { [DllImport("kernel32.dll")] private static extern int MultiByteToWideChar( uint CodePage, uint dwFlags, [MarshalAs(UnmanagedType.LPArray)] Byte[] lpMultiByteStr, int cbMultiByte, [Out, MarshalAs(UnmanagedType.LPArray)] Byte[] lpWideCharStr, int cchWideChar); [SqlFunction] public static SqlString ConvToUnicode(SqlInt32 codepage, SqlString multibyteString) { bool un; byte[] b = (byte[])iConvToMultibyteArray(multibyteString, out un); if (un) return (SqlString)ToUnicode((uint)(int)codepage, b); else return multibyteString; } private static SqlBinary iConvToMultibyteArray(SqlString multibyteString, out bool multibyte) { byte[] result; byte[] ch = multibyteString.GetUnicodeBytes(); if ((ch.Length >= 2) && (ch[1] == 0x00)) { result = new byte[ch.Length / 2]; for (int i = 0; i < ch.Length / 2; i++) { result[i] = ch[i * 2]; } multibyte = true; } else { result = ch;// new byte[ch.Length]; multibyte = false; } return (SqlBinary)result; } } !!!!Alternative Managed API: Do you know one? Please contribute it! Documentation: MultiByteToWideChar@msdn on MSDN
Edit kernel32.multibyt...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.