in reply to Encoding problem on SOAP web server

Hello :)

This is not the solution at your problem but your test is wrong, you said:
sub test { my $response = "ייי"; utf8::encode($response); return $response; }
should be:
$response = utf8::encode($response);

Replies are listed 'Best First'.
Re^2: Encoding problem on SOAP web server
by Anonymous Monk on Jan 12, 2016 at 11:33 UTC

    I think you are wrong.

    utf8::encode($string) modifies in-place passed var and return nothing.

    http://perldoc.perl.org/utf8.html :

    utf8::encode($string) Converts in-place the character sequence to the corresponding octet sequence in UTF-X. That is, every (possibly wide) character gets replaced with a sequence of one or more characters that represent the individual UTF-X bytes of the character. The UTF8 flag is turned off. Returns nothing.

      Yep right, strange (if we compare with other convertion functions) but if we go deeper, the input parameter should be a reference and here $response is a value ("ייי"), or maybe I don't understand something! Can you explain that?!

      Edit (explanation)
      Thanks to choroba.
      Found in perlsub: http://perldoc.perl.org/perlsub.html

      if you called a function with two arguments, those would be stored in $_[0] and $_1 . The array @_ is a local array, but its elements are aliases for the actual scalar parameters. In particular, if an element $_[0] is updated, the corresponding argument is updated (or an error occurs if it is not updatable).
        sub no_reference { $_[0] =~ s/o/O/g; } $string = 'Bozo is a clown'; no_reference($string); print $string, "\n";
        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
        Why do you say "the input parameter should be a reference" ? This is not in the documentation.

        Why do you say "the input parameter should be a reference" ?

        This is not in the documentation.