Skip Menu |

This queue is for tickets about the MediaWiki-API CPAN distribution.

Report information
The Basics
Id: 38369
Status: resolved
Priority: 0/
Queue: MediaWiki-API

People
Owner: Nobody in particular
Requestors: web [...] kvinge.biz
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.12
Fixed in: (no value)



Subject: Double encoding.
Hi. This is my first bugreport/feature request. First of all I want to say that MediaWiki::Api is great work. I use Mediawiki::Api to parse wikitext, and recieve HTML code like this: #use wikiapi to store data. my $html = $mw->api( { action => 'parse', text => $data } ); $data is wikitext recived from mediawiki using the MediaWiki module. The text is already encoded in utf8, but the MediaWiki::Api still tries to encode this text into utf8 ( _encode_hashref_utf8() - line 534 ). The result is double-encoding. My wishlist is an option for "skip encoding", or some checks to see if the encoding is actually needed.
Show quoted text
> My wishlist is an option for "skip encoding", or some checks to see
if Show quoted text
> the encoding is actually needed.
I guess an option would be possible. I'm assuming you didn't get the utf-8 encoded html via the api right ? (As the perl module always returns perl strings) for example use MediaWiki::API; binmode STDOUT, ':utf8'; my $mw = MediaWiki::API->new(); $mw->{config}->{api_url} = 'http://en.wikipedia.org/w/api.php'; my $ref = $mw->get_page( { title => "Xinmin" } ); # get wiki text of page my $data = $ref->{'*'}; # parse page my $ref = $mw->api( { action => 'parse', text => $data } ); my $html = $ref->{parse}->{text}->{'*'}; print $html; works fine.
I have uploaded a new version with the feature as requested. You can call the API function with an additional skip_encoding option like so my $ref = $mw->api( { action => 'parse', text => $data }, { skip_encoding => 1 } ); Thanks for the kind words about the module. I am pleased it has been of use to you. Please consider rating it @ http://cpanratings.perl.org/rate/?distribution=MediaWiki-API (Which should help encourage others to try it)