in reply to Re: Unicode/Wide strings and XS
in thread Unicode/Wide strings and XS

Yes, see above where I mentioned SvPVutf8() and sv_utf8_upgrade(). These don't seem to work. Perhaps "Perl Unicode" and "UTF8" are not the same thing as a "Wide String" as refered to by the Win32 API?

Update:

Here's an example of what I'm doing:

// Nodename is SV* holding "examplenode" printf("Nodename=[%s]\n", SvPV_nolen(Nodename)); // output: "Nodename= +[examplenode]" sv_utf8_upgrade(Nodename); wprintf(L"Got [%s]\n", (wchar_t*)SvPVutf8_nolen(Nodename)); // output: + "Nodename=[]"
Am I doing something wrong? The string seems to get clobbered, or it's in a format that Windows won't accept as a "wide string".

Replies are listed 'Best First'.
Re^3: Unicode/Wide strings and XS ("unicode")
by tye (Sage) on Jan 09, 2004 at 16:41 UTC
    Perhaps "Perl Unicode" and "UTF8" are not the same thing as a "Wide String" as refered to by the Win32 API?

    Unicode includes more than one encoding ("transformation format"). Perl uses UTF-8. Windows calls UTF-16 "UNICODE" or "wide" (or close to UTF-16 -- I don't think Windows supports multi-word characters which are part of UTF-16; [that is, Windows "UNICODE" appears to use only fixed-width 16-bit characters]). Windows calls UTF-8 "multi-byte".

    Update: And Perl doesn't support UTF-16 directly (there may be modules that deal with it), which could also be expressed as "Perl doesn't support multi-word nor single-word characters" using some of my loose terminology from above.

                    - tye

    [Updated]