Util: New util to truncate a string that won't split across a surrogate pair

This commit is contained in:
zzz
2018-01-10 17:39:58 +00:00
parent 50eb93deec
commit 541dae36d4
4 changed files with 25 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ import net.i2p.router.transport.TransportUtil;
import net.i2p.router.web.CSSHelper;
import net.i2p.router.web.HelperBase;
import net.i2p.router.web.NewsHelper;
import net.i2p.servlet.util.ServletUtil;
import net.i2p.stat.Rate;
import net.i2p.stat.RateStat;
import net.i2p.util.PortMapper;
@@ -575,7 +576,7 @@ public class SummaryHelper extends HelperBase {
if (name.length() <= 32)
buf.append(DataHelper.escapeHTML(name));
else
buf.append(DataHelper.escapeHTML(name.substring(0,29))).append("&hellip;");
buf.append(DataHelper.escapeHTML(ServletUtil.truncate(name, 29))).append("&hellip;");
buf.append("</a></b></td>\n");
LeaseSet ls = _context.netDb().lookupLeaseSetLocally(h);
if (ls != null && _context.tunnelManager().getOutboundClientTunnelCount(h) > 0) {