WideCharToMultiByte: Unterschied zwischen den Versionen

Aus API-Wiki
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: __NOTOC__ Die API-Funktion WideCharToMultiByte gibt Auskunft über XYZ. <code vb> Declare Function WideCharToMultiByte lib "kernel32.dll" ( _ ByV...)
(kein Unterschied)

Version vom 21. Oktober 2008, 18:53 Uhr

Die API-Funktion WideCharToMultiByte gibt Auskunft über XYZ.

Declare Function WideCharToMultiByte lib "kernel32.dll" ( _

                ByVal CodePage As Long, _
                ByVal dwFlags As Long, _
                ByVal lpWideCharStr As String, _
                ByVal cchWideChar As Long, _
                ByVal lpMultiByteStr As String, _
                ByVal cchMultiByte As Long, _
                ByVal lpDefaultChar As String, _
                ByVal lpUsedDefaultChar As Long) As Long

'"Windows Mobile" "Windows Embedded CE" 'This function maps a wide-character string to a new character string. The new character string is not necessarily 'from a multibyte character set

'Parameter 'CodePage '[in] Code page used to perform the conversion. 'You can set this parameter to any code page that is installed or available in the system. You can also specify one 'of the values shown in the following table. '(When SYSGEN_LOCUSA is set, only the 1252 and 437 code pages are supported)

'dwFlags '[in] Handling of unmapped characters. The function performs more quickly when none of these flags is set. 'The flag constants are described in the following table. Private Const WC_DISCARDNS As Long = &H10 Private Const WC_SEPCHARS As Long = &H20 Private Const WC_DEFAULTCHAR As Long = &H40 Private Const WC_COMPOSITECHECK As Long = &H200 'When WC_COMPOSITECHECK is specified, the function converts composite characters to precomposed characters. 'A composite character consists of a base character and a nonspacing character, each having different character values. 'A precomposed character has a single character value for a base/nonspacing character combination. In the character è, 'the e is the base character, and the accent grave mark is the nonspacing character. 'When an application specifies WC_COMPOSITECHECK, it can use the last three flags in this list '(WC_DISCARDNS, WC_SEPCHARS, and WC_DEFAULTCHAR) to customize the conversion to precomposed characters. 'These flags determine the function's behavior when there is no precomposed mapping for a base/nonspace character 'combination in a wide-character string. 'These last three flags can only be used if the WC_COMPOSITECHECK flag is set. 'The function's default behavior is to generate separate characters (WC_SEPCHARS) for unmapped composite characters. ' 'lpWideCharStr '[in] Pointer to the wide-character string to be converted. ' 'cchWideChar '[in] Number of Unicode (16-bit) characters in the string pointed to by the lpWideCharStr parameter. 'If this value is –1, the string is assumed to be null-terminated and the length is calculated automatically. ' 'lpMultiByteStr '[out] Pointer to the buffer to receive the translated string. ' 'cbMultiByte '[in] Size, in bytes, of the buffer pointed to by the lpMultiByteStr parameter. If this value is zero, the function 'returns the number of bytes required for the buffer. (In this case, the lpMultiByteStr buffer is not used.) ' 'lpDefaultChar '[in] Pointer to the character used if a wide character cannot be represented in the specified code page. 'If this parameter is NULL, a system default value is used. 'The function is faster when both lpDefaultChar and lpUsedDefaultChar are NULL. ' 'lpUsedDefaultChar '[in, out] Pointer to a flag that indicates whether a default character was used. ' 'The flag is set to TRUE if one or more wide characters in the source string cannot be represented in the specified 'code page. Otherwise, the flag is set to FALSE. 'This parameter can be NULL. 'The function is faster when both lpDefaultChar and lpUsedDefaultChar are NULL.


' Return Value 'The number of bytes written to the buffer pointed to by lpMultiByteStr indicates success if cbMultiByte is nonzero,. 'The required size, in bytes, for a buffer that can receive the translated string indicates success if cbMultiByte 'is zero,. 'Zero indicates failure. To get extended error information, call GetLastError. 'Possible values for GetLastError include the following: 'ERROR_INSUFFICIENT_BUFFER 'ERROR_INVALID_FLAGS 'ERROR_INVALID_PARAMETER ' ' Remarks 'If the lpMultiByteStr and lpWideCharStr pointers are the same, the function fails, and GetLastError returns 'ERROR_INVALID_PARAMETER. An application can use the lpDefaultChar parameter to change the default character 'used for the conversion. ' 'WideCharToMultiByte operates most efficiently when both lpDefaultChar and lpUsedDefaultChar are NULL. 'The behavior of WideCharToMultiByte for the four combinations of lpDefaultChar and lpUsedDefaultChar is shown 'in the following table. ' 'lpDefaultChar lpUsedDefaultChar Result 'NULL NULL No default checking. This is the most efficient, quick way to use this function. 'non -Null NULL Uses the specified default character, but does not set lpUsedDefaultChar. 'NULL non -Null Uses the system default character and sets lpUsedDefaultChar if necessary. 'non -Null non -Null Uses the specified default character and sets lpUsedDefaultChar if necessary. ' ' ' Requirements 'Header winnls.h 'Library coredll.lib 'Windows Embedded CE Windows CE 1.01 and later 'Windows Mobile Windows Mobile Version 5.0 and later ' ' See Also 'Reference 'Unicode Functions 'MultiByteToWideChar

Parameter

CodePage

Beschreibung

dwFlags

Beschreibung

lpWideCharStr

Beschreibung

cchWideChar

Beschreibung

lpMultiByteStr

Beschreibung

cchMultiByte

Beschreibung

lpDefaultChar

Beschreibung

lpUsedDefaultChar

Beschreibung


Rückgabe(n)

Die Funktion gibt einen Wert des Types Long zurück.



[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)


[OPTIONAL] Verwandte Funktionen

Api1 - Beschreibung
Api2 - Beschreibung


Verweise


[PFLICHT] Quelle(n)

  • MSDN US-Libary (nach Möglichkeit Link auf die Beschreibung).
  • Andere Quellen (falls vorhanden)