| 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 |
// Revision 1.2 2003/03/10 23:25:02 joko |
| 22 |
// + fixed metadata for phpDocumentor |
// + fixed metadata for phpDocumentor |
| 23 |
// |
// |
| 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; |
| 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() { |
| 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])) { |
| 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])) { |
| 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 |
} |
} |