Here you can find the source of encodeBackslashAhead(char c, char next, Appendable buffer)
private static void encodeBackslashAhead(char c, char next, Appendable buffer) throws IOException
//package com.java2s; //License from project: GNU General Public License import java.io.IOException; public class Main { /** encode a char in Wiki format and append it to a buffer */ private static void encodeBackslashAhead(char c, char next, Appendable buffer) throws IOException { if (Character.isWhitespace(c)) { if (Character.isWhitespace(next) || next == Character.MAX_VALUE) return; else/* w w w .j av a 2 s . c o m*/ buffer.append('_'); } else { String hex = Integer.toHexString(c); buffer.append("\\u"); for (int len = hex.length(); len < 4; len++) { buffer.append('0'); } buffer.append(hex); } } }