CharW function

Requires: GfaWinx.lg32

Purpose

Returns the null-terminated UNICODE string, without the terminating zeros.

Syntax

wtxt = CharW(adr)

wTxt : string
adr: long expression

Description

As the built-in function Char{address} the CharW() function returns a string with the contents of a piece of memory starting with address adr until the two terminating zeros are reached. The two termination null characters are not included. The returned string can be passed to Ansi() to convert the UNICODE text to Ansi. The adr parameter must point to a valid UNICODE string. An invalid address might throw an Access Denied exception.

Example

$Library "gfawinx"

Dim pws As Long, sWide As String, sAnsi As String

' Set pws to a valid memory address, for instance

' a value returned from an API function.

sWide = CharW(pws)      ' the UNICODE string

sAnsi = Ansi(sWide)     ' the ANSI version

Remarks

The CharW() function is useful when an API function returns a pointer to UNICODE text.

See Also

Char{}, Ansi(), StrPeek, Wide

{Created by Sjouke Hamstra; Last updated: 24/08/2021 by James Gaite}