cvs: smarty / NEWS /libs/plugins modifier.escape.php

"Monte Ohrt" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmohrt1084390836@cvsserver>
mohrt		Wed May 12 15:40:36 2004 EDT

  Modified files:              
    /smarty	NEWS 
    /smarty/libs/plugins	modifier.escape.php 
  Log:
  add 'nonstd' escape modifier
  
  
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.451&r2=1.452&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.451 smarty/NEWS:1.452
--- smarty/NEWS:1.451	Fri May  7 18:50:11 2004
+++ smarty/NEWS	Wed May 12 15:40:36 2004
@@ -1,3 +1,5 @@
+  - add 'nonstd' to escape modifier for escaping non-std chars,
+    such as ms doc quote (Monte)
   - adjusted textformat to not output wrap chars after last para
     (Monte)
   - use tempnam() instead of unqid() to create better temporary files in
http://cvs.php.net/diff.php/smarty/libs/plugins/modifier.escape.php?r1=1.15&r2=1.16&ty=u
Index: smarty/libs/plugins/modifier.escape.php
diff -u smarty/libs/plugins/modifier.escape.php:1.15 smarty/libs/plugins/modifier.escape.php:1.16
--- smarty/libs/plugins/modifier.escape.php:1.15	Fri Apr 30 10:50:17 2004
+++ smarty/libs/plugins/modifier.escape.php	Wed May 12 15:40:36 2004
@@ -62,7 +62,22 @@
             
         case 'mail':
             // safe way to display e-mail address on a web page
-            return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '),$string);
+            return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $string);
+            
+        case 'nonstd':
+           // escape non-standard chars, such as ms document quotes
+           $_res = '';
+           for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
+               $_ord = ord($string{$_i});
+               // non-standard char, escape it
+               if($_ord >= 126){
+                   $_res .= '&#' . $_ord . ';';
+               }
+               else {
+                   $_res .= $string{$_i};
+               }
+           }
+           return $_res;
 
         default:
             return $string;

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.