Skip to content

Instantly share code, notes, and snippets.

@poppen
Created August 25, 2009 10:01
Show Gist options
  • Select an option

  • Save poppen/174611 to your computer and use it in GitHub Desktop.

Select an option

Save poppen/174611 to your computer and use it in GitHub Desktop.
diff --git a/lib/MENTA.pm b/lib/MENTA.pm
index a68fa7a..9fc6d1e 100644
--- a/lib/MENTA.pm
+++ b/lib/MENTA.pm
@@ -272,13 +272,32 @@ sub static_file_path {
# HTTP の入り口んとこで decode させる用
sub decode_input {
- my ($txt, $fb) = @_;
- if (MENTA->context->config->{menta}->{support_mobile}) {
- require_once('Encode.pm');
- Encode::decode(_mobile_encoding(), $txt, $fb);
- } else {
- utf8::decode($txt);
- $txt;
+ if (wantarray) {
+ my (@txts, $fb) = @_;
+ my @result = ();
+
+ if (MENTA->context->config->{menta}->{support_mobile}) {
+ require_once('Encode.pm');
+ foreach my $txt (@txts) {
+ push( @result, Encode::decode(_mobile_encoding(), $txt, $fb) );
+ }
+ @result;
+ } else {
+ foreach my $txt (@txts) {
+ push( @result, utf8::decode($txt) );
+ }
+ @result;
+ }
+ }
+ else {
+ my ($txt, $fb) = @_;
+ if (MENTA->context->config->{menta}->{support_mobile}) {
+ require_once('Encode.pm');
+ Encode::decode(_mobile_encoding(), $txt, $fb);
+ } else {
+ utf8::decode($txt);
+ $txt;
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment