Replace utils’ Hex by Guava’s BaseEncoding.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 17 Jan 2013 16:19:55 +0000 (17:19 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 17 Jan 2013 16:19:55 +0000 (17:19 +0100)
src/main/java/net/pterodactylus/sone/template/JavascriptFilter.java

index fe3e130..9b8cd7e 100644 (file)
@@ -19,10 +19,11 @@ package net.pterodactylus.sone.template;
 
 import java.util.Map;
 
-import net.pterodactylus.util.number.Hex;
 import net.pterodactylus.util.template.Filter;
 import net.pterodactylus.util.template.TemplateContext;
 
+import com.google.common.io.BaseEncoding;
+
 /**
  * Escapes double quotes, backslashes, carriage returns and line feeds, and
  * additionally encloses a given string with double quotes to make it possible
@@ -56,7 +57,7 @@ public class JavascriptFilter implements Filter {
                                javascriptString.append('\\');
                                javascriptString.append(c);
                        } else if (c < 32) {
-                               javascriptString.append("\\x").append(Hex.toHex((byte) c));
+                               javascriptString.append("\\x").append(BaseEncoding.base16().lowerCase().encode(new byte[] { (byte) c }));
                        } else {
                                javascriptString.append(c);
                        }