private String translateString(final String trantab, String inbuf) {
   try {
     if (inbuf.length() == 0) {
       return "";
     }
     HyphenatedString hyphenatedInbuf = null;
     boolean preHyphenated =
         inbuf.contains(String.valueOf(TXT_SOFT_HYPHEN)) || inbuf.contains(String.valueOf('-'));
     if (preHyphenated) {
       hyphenatedInbuf = new HyphenatedString(inbuf, TXT_SOFT_HYPHEN);
       inbuf = hyphenatedInbuf.getUnhyphenatedString();
     }
     final int inlen = inbuf.length();
     final int maxOutlen = OUT_IN_RATIO * inlen;
     final byte[] inbufArray = inbuf.getBytes(encoding);
     final byte[] outbufArray = new byte[charSize * maxOutlen];
     final IntByReference pInlen = new IntByReference(inlen);
     final IntByReference pOutlen = new IntByReference(maxOutlen);
     int[] outputPosArray = null;
     if (preHyphenated) {
       outputPosArray = new int[maxOutlen];
     }
     if (INSTANCE.lou_translate(
             trantab,
             inbufArray,
             pInlen,
             outbufArray,
             pOutlen,
             null,
             null,
             null,
             outputPosArray,
             null,
             0)
         == 0) {
       throw new RuntimeException("Unable to complete translation");
     }
     int outlen = pOutlen.getValue();
     String outbuf = new String(outbufArray, 0, outlen * charSize, encoding);
     if (preHyphenated) {
       try {
         outputPosArray = Arrays.copyOf(outputPosArray, outlen);
         boolean[] inHyphenPos = hyphenatedInbuf.getHyphenPoints();
         boolean[] outHyphenPos = convertHyphenPos(inHyphenPos, outputPosArray);
         HyphenatedString hyphenatedOutbuf = new HyphenatedString(outbuf, outHyphenPos);
         outbuf = hyphenatedOutbuf.getFullyHyphenatedString(BRL_SOFT_HYPHEN);
         // Replace 't' hyphen points after a hard hyphen (not a non-breaking hyphen) by 'm'
         outbuf = outbuf.replaceAll("-" + BRL_SOFT_HYPHEN, BRL_HARD_HYPHEN);
       } catch (RuntimeException e) {
         // Don't hyphenate the text when an exception occurs.
       }
     }
     // Replace non-breaking hyphens with a normal hyphen
     outbuf = outbuf.replaceAll("\u2011", "-");
     return outbuf;
   } catch (UnsupportedEncodingException e) {
     throw new RuntimeException("Encoding not supported by JVM:" + encoding);
   }
 }
 private Louis() {
   INSTANCE = (LouisLibrary) Native.loadLibrary(("louis"), LouisLibrary.class);
   charSize = INSTANCE.lou_charSize();
   switch (charSize) {
     case 2:
       encoding = "UTF-16LE";
       break;
     case 4:
       encoding = "UTF-32LE";
       break;
     default:
       throw new RuntimeException("unsuported char size configured in liblouis: " + charSize);
   }
 }
 public String version() {
   return INSTANCE.lou_version();
 }
 public void louFree() {
   INSTANCE.lou_free();
 }