Java Encode encodeBackslashAhead(char c, char next, Appendable buffer)

Here you can find the source of encodeBackslashAhead(char c, char next, Appendable buffer)

Description

encode a char in Wiki format and append it to a buffer

License

Open Source License

Declaration

private static void encodeBackslashAhead(char c, char next, Appendable buffer) throws IOException 

Method Source Code


//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);
        }
    }
}

Related

  1. encodeAddresses(String string, String charset)
  2. encodeArguments(final String arg)
  3. encodeArray(String[] sourceArray, String sysCharset, String charset)
  4. encodeAsModifiedUTF8(String str)
  5. encodeAttribute(String value)
  6. encodeCodePoolData(InputStream input)
  7. encodedInputStreamReader(InputStream stream, String encoding)
  8. encodedStringToProperties(String theEncodedPropertyString)
  9. encodeEmail(String s)