Skip to content

PetrGlad/utf8-decoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reactive non blocking parser for UTF-8 encoding

Download

Dependency for build.gradle:

repositories {
  jcenter()
}

dependencies {
      compile 'net.readmarks:utf8-decoder:2.0.0'
}

Usage example

import net.readmarks.utf8.Utf8Decoder2;
class Utf8Printer {
  static void printDecodedUtf8(byte[] utf8bytes) {
    final Utf8decoder2 parser = new Utf8decoder2(System.out.print, 2048);
    parser.put(utf8bytes); // You can call this multiple times.
    parser.end(); // Check encoding and flush at end of input stream.
  }
}

This parser allows incoming data be parsed incrementally without blocking current thread while waiting for incoming data. This allows to avoid blocking current thread while waiting for new data. With this parser you do not call a function to obtain input but instead call this parser whenever new piece of input data is available.

References