Author: mcpierce Date: Tue Feb 12 20:36:19 2013 New Revision: 1445344 URL: http://svn.apache.org/r1445344 Log: QPID-4544: Perl bindings now support UTF8 encoding
Modifies the swig bindings to properly work with UTF8 encoded strings. Contributed by: Jimmy Jones <[email protected]> Modified: qpid/trunk/qpid/cpp/bindings/qpid/perl/t/Message.t qpid/trunk/qpid/cpp/bindings/swig_perl_typemaps.i Modified: qpid/trunk/qpid/cpp/bindings/qpid/perl/t/Message.t URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/perl/t/Message.t?rev=1445344&r1=1445343&r2=1445344&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/bindings/qpid/perl/t/Message.t (original) +++ qpid/trunk/qpid/cpp/bindings/qpid/perl/t/Message.t Tue Feb 12 20:36:19 2013 @@ -259,6 +259,13 @@ my $map = qpid::messaging::decode_map($m ok ($map->{name} eq "With\x00null", "Nulls embedded in map values work."); +# Unicode strings shouldn't be broken +$content = { id => 1234, name => "Euro=\x{20AC}" }; +qpid::messaging::encode($content, $message); +$map = qpid::messaging::decode_map($message); +ok ($map->{name} eq "Euro=\x{20AC}", + "Unicode strings encoded correctly."); + # content size # content size is correct my $content_size = int(rand(256)); Modified: qpid/trunk/qpid/cpp/bindings/swig_perl_typemaps.i URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/swig_perl_typemaps.i?rev=1445344&r1=1445343&r2=1445344&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/bindings/swig_perl_typemaps.i (original) +++ qpid/trunk/qpid/cpp/bindings/swig_perl_typemaps.i Tue Feb 12 20:36:19 2013 @@ -49,7 +49,11 @@ else if (SvPOK(value)) { STRLEN len; char *ptr = SvPV(value, len); - return qpid::types::Variant(std::string(ptr, len)); + qpid::types::Variant v = qpid::types::Variant(std::string(ptr,len)); + if (SvUTF8(value)) { + v.setEncoding("utf8"); + } + return v; } } return qpid::types::Variant(); @@ -98,6 +102,9 @@ case qpid::types::VAR_STRING : { const std::string val(v->asString()); result = newSVpvn(val.c_str(), val.size()); + if( v->getEncoding() == "utf8" ) { + SvUTF8_on(result); + } break; } case qpid::types::VAR_MAP : { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
