/[cvs]/nfo/php/libs/org.netfrag.glib/Data/Encode.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/Data/Encode.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Mon Feb 3 14:49:37 2003 UTC revision 1.4 by joko, Sun Jun 20 23:01:37 2004 UTC
# Line 1  Line 1 
1  <?  <?
2    /**
3     * This file contains the Data::Encode class.
4     *
5     * @author Andreas Motl <andreas.motl@ilo.de>
6     * @package org.netfrag.glib
7     * @name Data::Encode
8     *
9     */
10    
11  //    -------------------------------------------------------------------------  //    -------------------------------------------------------------------------
12  //    $Id$  //    $Id$
13  //    -------------------------------------------------------------------------  //    -------------------------------------------------------------------------
14  //    $Log$  //    $Log$
15    //    Revision 1.4  2004/06/20 23:01:37  joko
16    //    fix: from/to UTF-8 now also handles plain strings as arguments
17    //
18    //    Revision 1.3  2004/06/16 15:17:03  joko
19    //    now also en-/decodes hash-keys
20    //
21    //    Revision 1.2  2003/03/10 23:25:02  joko
22    //    + fixed metadata for phpDocumentor
23    //
24  //    Revision 1.1  2003/02/03 14:49:37  joko  //    Revision 1.1  2003/02/03 14:49:37  joko
25  //    + initial commit  //    + initial commit
26  //    + refactored from flib/Application/i18n/TextEncode.php  //    + refactored from flib/Application/i18n/TextEncode.php
# Line 16  Line 34 
34  //    -------------------------------------------------------------------------  //    -------------------------------------------------------------------------
35    
36    
37    /**
38     * --- Data::Encode
39     *
40     * @author Andreas Motl <andreas.motl@ilo.de>
41     * @package org.netfrag.glib
42     * @subpackage Data
43     * @name Data::Encode
44     *
45     */
46  class Data_Encode {  class Data_Encode {
47        
48    var $payload;    var $payload;
49      var $result;
50    
51    function Data_Encode(&$payload, $args = array()) {    function Data_Encode(&$payload, $args = array()) {
52      $this->payload = &$payload;      $this->payload = &$payload;
# Line 28  class Data_Encode { Line 56  class Data_Encode {
56      return $this->payload;      return $this->payload;
57    }    }
58        
59      function get_result() {
60        return $this->result;
61      }
62      
63    function toUTF8() {    function toUTF8() {
64      $this->_iso_2_utf8($this->payload);      $this->_iso_2_utf8($this->payload, $this->result);
65    }    }
66        
67    function toISO() {    function toISO() {
68      $this->_utf8_2_iso($this->payload);      $this->_utf8_2_iso($this->payload, $this->result);
69    }    }
70    
71    function toHTML() {    function toHTML() {
# Line 41  class Data_Encode { Line 73  class Data_Encode {
73    }    }
74    
75        
76    function _utf8_2_iso(&$payload) {    function _utf8_2_iso_OLD(&$payload) {
77      if (is_array($payload)) {      if (is_array($payload)) {
78        foreach ($payload as $key => $val) {        foreach ($payload as $key => $val) {
79          if (is_array($payload[$key])) {          if (is_array($payload[$key])) {
# Line 53  class Data_Encode { Line 85  class Data_Encode {
85      }      }
86    }    }
87        
88    function _iso_2_utf8(&$payload) {    function _iso_2_utf8_OLD(&$payload) {
89      if (is_array($payload)) {      if (is_array($payload)) {
90        foreach ($payload as $key => $val) {        foreach ($payload as $key => $val) {
91          if (is_array($payload[$key])) {          if (is_array($payload[$key])) {
# Line 65  class Data_Encode { Line 97  class Data_Encode {
97      }      }
98    }    }
99        
100      function _utf8_2_iso(&$payload, &$result) {
101        if (is_array($payload)) {
102          foreach ($payload as $key => $val) {
103            if (is_array($val)) {
104              $this->_utf8_2_iso($val, $result[$key]);
105            } else {
106              $this->_utf8_2_iso_scalar($key);
107              $this->_utf8_2_iso_scalar($val);
108              $result[$key] = $val;
109            }
110          }
111        } elseif (is_string($payload)) {
112          $this->_utf8_2_iso_scalar($payload);
113          $result = $payload;
114        }
115      }
116    
117      function _iso_2_utf8(&$payload, &$result) {
118        if (is_array($payload)) {
119          foreach ($payload as $key => $val) {
120            if (is_array($val)) {
121              $this->_iso_2_utf8($val, $result[$key]);
122            } else {
123              $this->_iso_2_utf8_scalar($key);
124              $this->_iso_2_utf8_scalar($val);
125              $result[$key] = $val;
126            }
127          }
128        } elseif (is_string($payload)) {
129          $this->_iso_2_utf8_scalar($payload);
130          $result = $payload;
131        }
132      }
133      
134    function _utf8_2_iso_scalar(&$scalar) {    function _utf8_2_iso_scalar(&$scalar) {
135      $scalar = utf8_decode($scalar);      $scalar = utf8_decode($scalar);
136    }    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed