in reply to Unicode/Wide strings and XS

Did you read "Using Unicode in XS" in perlunicode?

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Unicode/Wide strings and XS
by meetraz (Hermit) on Jan 09, 2004 at 15:46 UTC
    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".
      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]