LOCAL w AS WSTRING | STATIC w AS WSTRING | GLOBAL w AS WSTRINGV14 allocates WSTRING descriptors in the stack frame or static storage. The descriptor contains: data pointer, length (UTF-16 code units), capacity, and flags.
w$ = s$ (STRING to WSTRING) | s$ = w$ (WSTRING to STRING)LOCAL s AS STRING, w AS WSTRING s = "Hello" w = s ' MultiByteToWideChar (CP_ACP -> UTF-16) s = w ' WideCharToMultiByte (UTF-16 -> CP_ACP)
; Get source STRING pointer -> RCX ; WideCharToMultiByte or MultiByteToWideChar mov rcx, 65001 ; CP_UTF8 / CP_ACP xor rdx, rdx ; dwFlags = 0 mov r8, [rbp - src_ptr] ; source mov r9, -1 ; null-terminated call [__imp_MultiByteToWideChar] ; returns required buffer size
PRINT w$Lowered through a temporary narrow conversion buffer (WideCharToMultiByte), then output via the existing WriteFile console path.
LEN(w$) | STRPTR(w$)LEN returns UTF-16 code-unit count from the descriptor. STRPTR returns the raw WCHAR* data pointer.
LOCAL w AS WSTRING w = "Hello" PRINT LEN(w) ' 5 (code units) PRINT STRPTR(w) ' address of wchar_t data
w1$ = w2$ | w1$ <> w2$ | w1$ < w2$Mixed STRING/WSTRING expressions auto-promote to WSTRING. Comparison uses memcmp on UTF-16 byte spans.
w$ = w1$ + w2$ | w$ = s$ + w$ (mixed)Uses pb_wstr64_concat runtime. Mixed STRING/WSTRING operands are promoted to WSTRING before concatenation.
FUNCTION name(BYVAL w AS WSTRING) AS WSTRINGFull scalar return path. Parameters can be BYVAL or default BYREF WSTRING.
FUNCTION Greet(BYVAL name AS WSTRING) AS WSTRING
LOCAL w AS WSTRING
w = "Hello, " + name
FUNCTION = w
END FUNCTION