### Question:
DefaultSolrFieldNameEncoder implements SolrFieldNameEncoder { @Override public String encode(final String fieldName) { if (fieldName == null) { return null; } int offset = 0; final int length = fieldName.length(); final StringBuilder output = new StringBuilder(length); boolean dirty = false; while (offset < length) { final int codePoint = fieldName.codePointAt(offset); final char[] chars = Character.toChars(codePoint); if (needsEncoding(codePoint)) { encode(chars, output); dirty = true; } else { output.append(chars); } offset += chars.length; } return dirty ? output.toString() : fieldName; }  @Override String encode(final String fieldName); @Override String decode(String fieldName);  }### Answer:
@Test public void encode() { assertNull(encoder.encode(null)); assertSame("", encoder.encode("")); assertSame("a1_.-\u0103", encoder.encode("a1_.-\u0103")); assertEquals("$3A$20$5E$2B$24", encoder.encode(": ^+$")); }