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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Mon Feb 3 14:49:37 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
+ initial commit
+ refactored from flib/Application/i18n/TextEncode.php

1 joko 1.1 <?
2     // -------------------------------------------------------------------------
3     // $Id: TextEncode.php,v 1.2 2003/02/03 03:40:02 jonen Exp $
4     // -------------------------------------------------------------------------
5     // $Log: TextEncode.php,v $
6     // Revision 1.2 2003/02/03 03:40:02 jonen
7     // + added function 'toHTML()', for deep asci_2_html encoding (using htmlentities() )
8     //
9     // Revision 1.1 2002/11/12 05:42:30 joko
10     // + initial checkin
11     //
12     // -------------------------------------------------------------------------
13    
14    
15     class Data_Encode {
16    
17     var $payload;
18    
19     function Data_Encode(&$payload, $args = array()) {
20     $this->payload = &$payload;
21     }
22    
23     function &get() {
24     return $this->payload;
25     }
26    
27     function toUTF8() {
28     $this->_iso_2_utf8($this->payload);
29     }
30    
31     function toISO() {
32     $this->_utf8_2_iso($this->payload);
33     }
34    
35     function toHTML() {
36     $this->_asci_2_html($this->payload);
37     }
38    
39    
40     function _utf8_2_iso(&$payload) {
41     if (is_array($payload)) {
42     foreach ($payload as $key => $val) {
43     if (is_array($payload[$key])) {
44     $this->_utf8_2_iso($payload[$key]);
45     } else {
46     $this->_utf8_2_iso_scalar($payload[$key]);
47     }
48     }
49     }
50     }
51    
52     function _iso_2_utf8(&$payload) {
53     if (is_array($payload)) {
54     foreach ($payload as $key => $val) {
55     if (is_array($payload[$key])) {
56     $this->_iso_2_utf8($payload[$key]);
57     } else {
58     $this->_iso_2_utf8_scalar($payload[$key]);
59     }
60     }
61     }
62     }
63    
64     function _utf8_2_iso_scalar(&$scalar) {
65     $scalar = utf8_decode($scalar);
66     }
67    
68     function _iso_2_utf8_scalar(&$scalar) {
69     $scalar = utf8_encode($scalar);
70     }
71    
72     function _asci_2_html_scalar(&$scalar) {
73     $scalar = htmlentities( trim($scalar) );
74     }
75    
76     function _asci_2_html(&$payload) {
77     if (is_array($payload)) {
78     foreach ($payload as $key => $val) {
79     if (is_array($payload[$key])) {
80     $this->_asci_2_html($payload[$key]);
81     } else {
82     $this->_asci_2_html_scalar($payload[$key]);
83     }
84     }
85     }
86     }
87    
88    
89     }
90    
91     ?>

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