New
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Utils.pm
index 9f672fe..6367761 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Utils.pm,v 1.17 2006-11-29 18:15:10 mike Exp $
+# $Id: Utils.pm,v 1.19 2006-12-05 17:19:35 mike Exp $
 
 package ZOOM::IRSpy::Utils;
 
@@ -36,7 +36,13 @@ sub isodate {
 # Template::Plugin both roll their own.  So I will do likewise.  D'oh!
 #
 sub xml_encode {
-    my($text, $fallback) = @_;
+    my($text, $fallback, $opts) = @_;
+    if (!defined $opts && ref $fallback) {
+       # The second and third arguments are both optional
+       $opts = $fallback;
+       $fallback = undef;
+    }
+    $opts = {} if !defined $opts;
 
     $text = $fallback if !defined $text;
     use Carp;
@@ -46,8 +52,11 @@ sub xml_encode {
     $text =~ s/&/&/g;
     $text =~ s/</&lt;/g;
     $text =~ s/>/&gt;/g;
-    $text =~ s/['']/&apos;/g;
+    # Internet Explorer can't display &apos; (!) so don't create it
+    #$text =~ s/['']/&apos;/g;
     $text =~ s/[""]/&quot;/g;
+    $text =~ s/ /&nbsp;/g if $opts->{nbsp};
+
     return $text;
 }