All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.restfb.json.UnicodeJsonWriter Maven / Gradle / Ivy

Go to download

RestFB is a simple and flexible Facebook Graph API client written in Java.

There is a newer version: 2024.14.0
Show newest version
package com.restfb.json;

import java.io.Writer;

public class UnicodeJsonWriter extends JsonWriter {

  UnicodeJsonWriter(Writer writer) {
    super(writer);
  }

  @Override
  protected char[] getReplacementChars(char ch) {

    if (ch == '\\') {
      return BS_CHARS;
    }
    if (ch == '"') {
      return QUOT_CHARS;
    }
    if (ch == '\n') {
      return LF_CHARS;
    }
    if (ch == '\r') {
      return CR_CHARS;
    }
    if (ch == '\t') {
      return TAB_CHARS;
    }
    if (ch < 0x20 || ch > 0x7f) {
      return new char[] { '\\', 'u', HEX_DIGITS[ch >> 12 & 0x000f], HEX_DIGITS[ch >> 8 & 0x000f],
          HEX_DIGITS[ch >> 4 & 0x000f], HEX_DIGITS[ch & 0x000f] };
    } else {
      return NO_CHARS;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy