LangIdEncDec { public static void lossyEncode(final CharSequence what, final Appendable to) throws IOException { int length = what.length(); if (length == 0) { return; } char first = what.charAt(0); if (Character.isLetter(first) || first == '_') { to.append(first); } else { to.append('_'); } for (int i = 1; i < length; i++) { char c = what.charAt(i); if (Character.isLetterOrDigit(c) || c == '_') { to.append(c); } else { to.append('_'); } } } private  LangIdEncDec(); static void lossyEncode(final CharSequence what, final Appendable to); static String lossyEncode(final String what);  }
@Test public void testLossyEnc() { Assert.assertEquals("_abc_d", LangIdEncDec.lossyEncode("1abc,d")); }
@Test @SuppressFBWarnings("ES_COMPARING_STRINGS_WITH_EQ") public void testLossyEnc2() { Assert.assertSame("abcd", LangIdEncDec.lossyEncode("abcd")); }