diff options
-rw-r--r-- | perl-install/c/stuff.xs.pl | 26 | ||||
-rw-r--r-- | perl-install/common.pm | 9 |
2 files changed, 34 insertions, 1 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl index 60eb94b92..b1ec93bd2 100644 --- a/perl-install/c/stuff.xs.pl +++ b/perl-install/c/stuff.xs.pl @@ -520,6 +520,32 @@ iconv(s, from_charset, to_charset) OUTPUT: RETVAL +int +is_tagged_utf8(s) + SV *s + CODE: + RETVAL = SvUTF8(s); + OUTPUT: + RETVAL + +void +set_tagged_utf8(s) + SV *s + CODE: + SvUTF8_on(s); + +void +upgrade_utf8(s) + SV *s + CODE: + sv_utf8_upgrade(s); + +void +unset_tagged_utf8(s) + SV *s + CODE: + SvUTF8_off(s); + char * standard_charset() CODE: diff --git a/perl-install/common.pm b/perl-install/common.pm index 0e431cbe4..ce86aa4a6 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -25,9 +25,16 @@ $SECTORSIZE = 512; #-##################################################################################### +sub sprintf_fixutf8 { + my $need_upgrade; + $need_upgrade |= to_bool(c::is_tagged_utf8($_)) + 1 foreach @_; + if ($need_upgrade == 3) { c::upgrade_utf8($_) foreach @_ }; + sprintf shift, @_; +} + sub N { my $s = shift @_; my $t = translate($s); - sprintf $t, @_; + sprintf_fixutf8 $t, @_; } sub N_ { $_[0] } |