Changeset 520

Show
Ignore:
Timestamp:
04/14/07 17:27:10 (1 year ago)
Author:
schst
Message:

Added encoding helper to move encoding stuff out of the JSON-RPC processor

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/processors/stubJsonRpcProcessor.php

    r519 r520  
    1313                      'net.stubbles.reflection.reflection', 
    1414                      'net.stubbles.service.annotations.stubWebMethodAnnotation', 
    15                       'net.stubbles.service.stubStatefulService'); 
     15                      'net.stubbles.service.stubStatefulService', 
     16                      'net.stubbles.util.encoding.stubEncodingHelper'); 
    1617 
    1718/** 
     
    259260        $fault = array( 
    260261                    'id'    => $reqId, 
    261                     'error' => utf8_encode($message) 
     262                    'error' => stubEncodingHelper::recursiveUtf8Encode($message) 
    262263                ); 
    263264        $faultEncoded = json_encode($fault); 
     
    274275        $response = array( 
    275276                    'id'     => $reqId, 
    276                     'result' => $this->recursiveUtf8Encode($result) 
     277                    'result' => stubEncodingHelper::recursiveUtf8Encode($result) 
    277278                ); 
    278279        $responseEncoded = json_encode($response); 
    279280        $this->response->write($responseEncoded); 
    280281    } 
    281  
    282    /** 
    283     * Encode the response in UTF-8 
    284     * 
    285     * @param mixed $value 
    286     * @return mixed 
    287     * @todo   add support for objects 
    288     */ 
    289     protected function recursiveUtf8Encode($value) { 
    290         if (is_string($value)) { 
    291             return utf8_encode($value); 
    292         } 
    293         if (is_array($value)) { 
    294             foreach ($value as $key => $val) { 
    295                 $value[$key] = $this->recursiveUtf8Encode($val); 
    296             } 
    297         } 
    298         return $value; 
    299     } 
    300282} 
    301283?>