Skip to content

Commit

Permalink
Item8730: fixing utf8
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/SoapPlugin@6790 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Mar 19, 2010
1 parent 8925014 commit 10ddd7d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
4 changes: 2 additions & 2 deletions data/System/SoapPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="micha" date="1269028908" format="1.1" version="1.6"}%
%META:TOPICINFO{author="ProjectContributor" date="1269028908" format="1.1" version="1.6"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%

Expand Down Expand Up @@ -146,7 +146,7 @@ Every message created by !SoapPlugin adds a set of foswiki-specific headers whic
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 19 Mar 2010: | rewrite of serializer; implemented =$valueof()= etc |
| 19 Mar 2010: | rewrite of serializer; implemented =$valueof()= etc; fixed UTF8 handling |
| 16 Mar 2010: | initial release |
| Dependencies: | %$DEPENDENCIES% |
| Home page: | Foswiki:Extensions/%TOPIC% |
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/SoapPlugin.pm
Expand Up @@ -16,7 +16,7 @@ use strict;
use Foswiki::Func ();

our $VERSION = '$Rev$';
our $RELEASE = '0.4';
our $RELEASE = '0.5';
our $SHORTDESCRIPTION = 'SOAP for Foswiki';
our $NO_PREFS_IN_TOPIC = 1;
our $baseWeb;
Expand Down
37 changes: 30 additions & 7 deletions lib/Foswiki/Plugins/SoapPlugin/Core.pm
Expand Up @@ -18,6 +18,8 @@ package Foswiki::Plugins::SoapPlugin::Core;
use strict;
use Foswiki::Plugins ();
use Foswiki::Plugins::SoapPlugin::Client();
use Unicode::MapUTF8 ();

our $baseWeb;
our $baseTopic;
our %clients;
Expand Down Expand Up @@ -200,14 +202,14 @@ sub stringify {
my $line = $params->{format};
$line = '$value' unless defined $line;

$line =~ s/\$(key|name)/($dataItem->name()||'')/ge;
$line =~ s/\$type/($dataItem->type()||'')/ge;
$line =~ s/\$uri/($dataItem->uri()||'')/ge;
$line =~ s/\$prefix/($dataItem->prefix()||'')/ge;
$line =~ s/\$attr\((.*?)\)/($dataItem->attr($1)||'')/ge;
$line =~ s/\$(key|name)/fromUtf8($dataItem->name()||'')/ge;
$line =~ s/\$type/fromUtf8($dataItem->type()||'')/ge;
$line =~ s/\$uri/fromUtf8($dataItem->uri()||'')/ge;
$line =~ s/\$prefix/fromUtf8($dataItem->prefix()||'')/ge;
$line =~ s/\$attr\((.*?)\)/fromUtf8($dataItem->attr($1)||'')/ge;
$line =~ s/\$index/$currentIndex/g;
$line =~ s/\$depth/$depth/g;
$line =~ s/\$valueof\((.*?)\)/($som->valueof($1||'')||'')/ge;
$line =~ s/\$valueof\((.*?)\)/fromUtf8($som->valueof($1||'')||'')/ge;

if ($line =~ /\$value\b/) {
my $value = $dataItem->value() ||'';
Expand Down Expand Up @@ -238,7 +240,7 @@ sub stringify {
} else {
push @values, ref($value);
}
$value = join('', @values);
$value = fromUtf8(join('', @values));
$line =~ s/\$value\b/$value/g;
}

Expand All @@ -250,5 +252,26 @@ sub stringify {
return $params->{header}.join($params->{separator}, @lines).$params->{footer};
}

###############################################################################
sub toUtf8 {
my $text = shift;

$text = Unicode::MapUTF8::to_utf8(-string=>$text, -charset=>$Foswiki::cfg{Site}{CharSet})
if $Foswiki::cfg{Site}{CharSet} !~ /^utf-?8$/i;

return $text;
}

###############################################################################
sub fromUtf8 {
my $text = shift;

$text = Unicode::MapUTF8::from_utf8(-string=>$text, -charset=>$Foswiki::cfg{Site}{CharSet})
if $Foswiki::cfg{Site}{CharSet} !~ /^utf-?8$/i;

return $text;
}


1;

1 change: 1 addition & 0 deletions lib/Foswiki/Plugins/SoapPlugin/DEPENDENCIES
@@ -1,2 +1,3 @@
SOAP::Lite,>=0.71,CPAN,Required. install from CPAN
libxml2,>=2.7.5,,Required.
Unicode::MapUTF8,>=1.11,cpan,Required.

0 comments on commit 10ddd7d

Please sign in to comment.