/[cvs]/nfo/php/libs/org.netfrag.flib/Application/i18n/TextEncode.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.flib/Application/i18n/TextEncode.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Mon Feb 3 03:40:02 2003 UTC (21 years, 7 months ago) by jonen
Branch: MAIN
Changes since 1.1: +27 -2 lines
+ added function 'toHTML()', for deep asci_2_html encoding (using htmlentities() )

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

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