proc WideCharToUtf8, .ptrWideChar
begin
        push    edx esi edi

        mov     esi, [.ptrWideChar]
        stdcall StrNew
        mov     edi, eax

.loop:
        stdcall DecodeUtf16, [esi]
        test    eax, eax
        jz      .end_string

        stdcall EncodeUtf8, eax

        stdcall StrCharCat, edi, eax
        jmp     .loop

.end_string:
        mov     eax, edi
        pop     edi esi edx
        return
endp