package org.simantics.scl.compiler.markdown.internal; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import gnu.trove.map.hash.TCharObjectHashMap; public class HtmlEscape { private static final Charset UTF8 = Charset.forName("UTF-8"); private static final TCharObjectHashMap ESCAPED_CHARS = new TCharObjectHashMap(); static { ESCAPED_CHARS.put('<', "<"); ESCAPED_CHARS.put('>', ">"); ESCAPED_CHARS.put('"', """); ESCAPED_CHARS.put('&', "&"); } public static CharSequence escape(CharSequence text) { int length = text.length(); for(int i=0;i= 128) { ByteBuffer bs = UTF8.encode(CharBuffer.wrap(new char[] {c})); for(int j=0;j