package org.openautonomousconnection.webserver.utils; import java.nio.charset.StandardCharsets; /** * Small HTML helpers for server-side rendering. */ public final class Html { private Html() { } /** * Escapes text for HTML. * * @param s input * @return escaped */ public static String esc(String s) { if (s == null) return ""; return s.replace("&", "&") .replace("<", "<") .replace(">", ">") .replace("\"", """); } /** * Encodes to UTF-8 bytes. * * @param html html * @return bytes */ public static byte[] utf8(String html) { return (html == null ? "" : html).getBytes(StandardCharsets.UTF_8); } /** * Simple page wrapper. * * @param title title * @param body body html * @return full html */ public static String page(String title, String body) { return """