tbusch has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, since 5.8.0 Perl strings are handled internally either as octet strings or as UTF-8 strings.

I need to link a C++ library that uses wide-characters (wchar_t) with perl to extend an existing CPAN package.

Is it true to assume that the stanard XS typemap that comes with perl is not capable to do the correct UTF-8 to wchar_t conversion or vice-versa ?

The standard typemap contains the following:

wchar_t * T_PV ... INPUT T_PV $var = ($type)SvPV_nolen($arg) ... OUTPUT T_PV sv_setpv((SV*)$arg, $var);

What would be a good replacement for this that would work with both forms of Perl internal strings ?

  • Comment on Correct Perl XS typemap for wchar_t strings for perl 5.8 and above
  • Download Code

Replies are listed 'Best First'.
Re: Correct Perl XS typemap for wchar_t strings for perl 5.8 and above
by Joost (Canon) on Oct 12, 2006 at 18:38 UTC