Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than kernel32, prefix the name with the module name and a period.
MultiByteToWideChar (kernel32)
.
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!
The MultiByteToWideChar API
3/16/2007 7:57:00 AM - -85.39.214.154
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).