Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(revision 6804)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(revision 6805)
@@ -5,4 +5,5 @@
 
 import java.awt.Color;
+import java.io.UnsupportedEncodingException;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
@@ -12,4 +13,5 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -524,4 +526,19 @@
             return s == null ? null : s.replace(target, replacement);
         }
+
+        /**
+         * Percent-encode a string. (See https://en.wikipedia.org/wiki/Percent-encoding)
+         * This is especially useful for data urls, e.g.
+         * <code>icon-image: concat("data:image/svg+xml,", URL_encode("<svg>...</svg>"));</code>
+         * @param s arbitrary string
+         * @return the encoded string
+         */
+        public static String URL_encode(String s) {
+            try {
+                return s == null ? null : URLEncoder.encode(s, "UTF-8");
+            } catch (UnsupportedEncodingException ex) {
+                throw new RuntimeException();
+            }
+        }
     }
 
