MultiByteToWideChar
Die API-Funktion MultiByteToWideChar konvertiert einen einbyte/mehrbyte-Character-String in einen Wide-Character-Unicode-String.
Declare Function MultiByteToWideChar lib "kernel32.dll" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As String, _
ByVal cchWideChar As Long) As Long
Parameter
CodePage
- die Codepage die bei der Konversion verwendet werden soll. Es kann jede im System installierte Codepage verwendet werden oder bspw eine aus der folgenden Liste:
die Liste zeigt mögliche Werte
Private Const CP_ACP As Long = 0 'ANSI Code Page
Private Const CP_OEMCP As Long = 1 'OEM code page
'Private Const CP_MACCP As Long = 2 'Not supported
'Private Const CP_THREAD_ACP As Long = 3 'Not supported
'Private Const CP_SYMBOL As Long = 42 'Not supported
Private Const CP_ANSI As Long = 1252 'Windows-1252
Private Const CP_UTF7 As Long = 65000 'UTF-7 code page
Private Const CP_UTF8 As Long = 65001 'UTF-8 code page
dwFlags
- Es kann eiinen Kombination aus folgenden Flags verwendet werden
Private Const MB_PRECOMPOSED As Long = &H1 'Always use precomposed characters — that is, characters in
'which a base character and a nonspacing character have a
'single character value. This is the default translation option.
'Cannot be used with MB_COMPOSITE.
Private Const MB_COMPOSITE As Long = &H2 'Always use composite characters — that is, characters in
'which a base character and a nonspacing character have
'different character values. Cannot be used with MB_PRECOMPOSED.
Private Const MB_USEGLYPHCHARS As Long = &H4 'Use glyph characters instead of control characters
Private Const MB_ERR_INVALID_CHARS As Long = &H8 'If the function encounters an invalid input character,
'it fails and Err.LastDllError returns ERROR_NO_UNICODE_TRANSLATION.
lpMultiByteStr
- [in] Zeiger zum Character String der konvertiert werden soll.
cchMultiByte
- [in] Größe, in Bytes, des Strings der konvertiert werden soll.
ist dieser Wert –1, wird vorausgesetzt da´ß der String Null-terminiert ist und die Länge wird automatisch ermittelt. lpWideCharStr
- [out] Zeiger auf einen Puffer der den übersetzten String empfängt.
cchWideChar
- [in] Größe, in Wide-Characters, des Puffers der den übersetzten String enthält.
Wenn hier Null übergeben wird, liefert die Funktion die erforderliche Größe in Wide-Characters zurück, aber es wird noch nichts übersetzt.
Rückgabe(n)
Anzahl der Wide-Characters die in den Puffer geschrieben wurden, wenn die Function erfporlgreich war und cchWideChar ist <> Null. Anmerkung: die zurückgegebene Länge enthält ein Null-Terminierungs-Zeichen.
[OPTIONAL] Beispiel
'Beispielcode...
[OPTIONAL] Hinweise
Diese Funktion setzt die ABC - Runtime Environment voraus. Diese ist kostenlos erhältlich unter: [Adresse].
[OPTIONAL] Betriebsystem
Die Funktion ist unter folgenden Betriebssystemen funktionsfähig:
- Windows NT 4.0
- Windows NT 5.0 (2000)
- Windows XP (ab SP2)
- Windows Vista (nur x64)
- Windows Mobile
- "Windows Embedded CE
[OPTIONAL] Verwandte Funktionen
Api1 - Beschreibung
Api2 - Beschreibung
Unicode Functions [MSDN-Link: http://msdn.microsoft.com/en-us/library/aa914568.aspx]
WideCharToMultiByte [MSDN-Link: http://msdn.microsoft.com/en-us/library/aa908730.aspx]
IsDBCSLeadByte [MSDN-Link: http://msdn.microsoft.com/en-us/library/aa908969.aspx]
Verweise
[PFLICHT] Quelle(n)
- MSDN US-Libary (http://msdn.microsoft.com/en-us/library/bb202786.aspx).
- Andere Quellen (falls vorhanden)