Show
Ignore:
Timestamp:
05/28/08 15:25:46 (5 years ago)
Author:
tokuhirom
Message:

fixed utf8 flag related bug.

Location:
lang/perl/Sledge-Plugin-JSON-XS/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Sledge-Plugin-JSON-XS/trunk/lib/Sledge/Plugin/JSON/XS.pm

    r6339 r12592  
    44use 5.00800; 
    55use JSON::XS; 
     6use Encode (); 
    67 
    78our $VERSION = '0.01'; 
     
    5051sub _add_callback { 
    5152    my ($self, $cb, $json) = @_; 
     53 
     54    if (Encode::is_utf8($cb)) { 
     55        $cb = Encode::encode('utf8', $cb); 
     56    } 
    5257 
    5358    my $output; 
  • lang/perl/Sledge-Plugin-JSON-XS/trunk/t/01_basic.t

    r6339 r12592  
    11use strict; 
    22use warnings; 
    3 use Test::More tests => 10; 
     3use Test::More tests => 12; 
     4use Encode; 
    45 
    56# ------------------------------------------------------------------------- 
     
    146147); 
    147148 
     149test( 
     150    'callback_flagged_utf8', 
     151    sub { 
     152        $REQ_HASH = { callback => decode_utf8('hoge') }; 
     153    }, 
     154    sub { 
     155        is_ex $page->r->{'print'}, 'hoge({"foo":"bar"});'; 
     156        ok( (!Encode::is_utf8($page->r->{'print'})), 'not flagged'); 
     157    }, 
     158); 
     159