Codota Logo
UTF8.encode
Code IndexAdd Codota to your IDE (free)

How to use
encode
method
in
com.wizzardo.tools.misc.UTF8

Best Java code snippets using com.wizzardo.tools.misc.UTF8.encode (Showing top 15 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: wizzardo/tools

public static byte[] encode(char[] chars) {
  return encode(chars, 0, chars.length);
}
origin: wizzardo/tools

public void toBytes(Supplier<byte[]> bytesSupplier, UTF8.BytesConsumer bytesConsumer) {
  UTF8.encode(buffer, 0, length, bytesSupplier, bytesConsumer);
}
origin: com.wizzardo.tools/tools-misc

public static byte[] encode(char[] chars) {
  return encode(chars, 0, chars.length);
}
origin: com.wizzardo.tools/tools-misc

public void toBytes(Supplier<byte[]> bytesSupplier, UTF8.BytesConsumer bytesConsumer) {
  UTF8.encode(buffer, 0, length, bytesSupplier, bytesConsumer);
}
origin: com.wizzardo.tools/tools-misc

public static byte[] encodeAndTrim(char[] chars, int off, int length, byte[] bytes) {
  int l = encode(chars, off, length, bytes);
  return Arrays.copyOf(bytes, l);
}
origin: wizzardo/tools

public static byte[] encodeAndTrim(char[] chars, int off, int length, byte[] bytes) {
  int l = encode(chars, off, length, bytes);
  return Arrays.copyOf(bytes, l);
}
origin: wizzardo/tools

@Override
public Writer append(char c) throws IOException {
  if (c < 128) {
    out.write((byte) c);
  } else {
    int l = UTF8.encode(c, bytes, 0);
    out.write(bytes, 0, l);
  }
  return this;
}
origin: com.wizzardo.tools/tools-misc

@Override
public void write(char[] chars, int off, int len) throws IOException {
  int limit = len + off;
  for (int i = off; i < limit; i += batchSize) {
    int l = UTF8.encode(chars, off, Math.min(limit - off, batchSize), bytes);
    out.write(bytes, 0, l);
  }
}
origin: com.wizzardo.tools/tools-misc

@Override
public Writer append(char c) throws IOException {
  if (c < 128) {
    out.write((byte) c);
  } else {
    int l = UTF8.encode(c, bytes, 0);
    out.write(bytes, 0, l);
  }
  return this;
}
origin: wizzardo/tools

@Override
public void write(char[] chars, int off, int len) throws IOException {
  int limit = len + off;
  for (int i = off; i < limit; i += batchSize) {
    int l = UTF8.encode(chars, off, Math.min(limit - off, batchSize), bytes);
    out.write(bytes, 0, l);
  }
}
origin: wizzardo/tools

public static byte[] encode(char[] chars, int off, int length) {
  byte[] bytes = new byte[count(chars, off, length)];
  encode(chars, off, length, bytes);
  return bytes;
}
origin: com.wizzardo.tools/tools-misc

public static byte[] encode(char[] chars, int off, int length) {
  byte[] bytes = new byte[count(chars, off, length)];
  encode(chars, off, length, bytes);
  return bytes;
}
origin: wizzardo/tools

@Test
public void encode() {
  char[] chars = new char[1];
  Charset utf8 = Charset.forName("UTF-8");
  for (char i = 0; i < Character.MAX_VALUE; i++) {
    chars[0] = i;
    Assert.assertArrayEquals("fails on " + (int) i, String.valueOf(i).getBytes(utf8), UTF8.encode(chars));
  }
}
origin: wizzardo/tools

@Test
public void encode_surrogates() {
  char[] chars = new char[2];
  Charset utf8 = Charset.forName("UTF-8");
  for (char i = '\uD800'; i < '\uDC00'; i++) {
    chars[0] = i;
    for (char j = '\uDC00'; j < '\uE000'; j++) {
      chars[1] = j;
      Assert.assertArrayEquals("fails on " + (int) i + " " + (int) j, new String(chars).getBytes(utf8), UTF8.encode(chars));
    }
  }
}
origin: wizzardo/tools

  private void test_supplier(final int bufferSize) throws UnsupportedEncodingException {
    String s = "€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€";
    char[] chars = s.toCharArray();

    final ByteArrayOutputStream out = new ByteArrayOutputStream();

    UTF8.encode(chars, 0, chars.length, new Supplier<byte[]>() {
      @Override
      public byte[] supply() {
        return new byte[bufferSize];
      }
    }, new UTF8.BytesConsumer() {
      @Override
      public void consume(byte[] buffer, int offset, int length) {
        out.write(buffer, offset, length);
      }
    });

    Assert.assertArrayEquals(s.getBytes("utf-8"), out.toByteArray());
  }
}
com.wizzardo.tools.miscUTF8encode

Popular methods of UTF8

  • decode
  • <init>
  • count
  • encodeAndTrim
  • highSurrogate
  • isMalformed3
  • isMalformed3_2
  • isMalformed4
  • isMalformed4_2
  • isMalformed4_3
  • isNotContinuation
  • isSupplementaryCodePoint
  • isNotContinuation,
  • isSupplementaryCodePoint,
  • isSurrogate,
  • lowSurrogate,
  • parseSurrogate,
  • toBytes

Popular in Java

  • Reading from database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • Kernel (java.awt.image)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now