Example usage for org.apache.lucene.util UnicodeUtil MAX_UTF8_BYTES_PER_CHAR

List of usage examples for org.apache.lucene.util UnicodeUtil MAX_UTF8_BYTES_PER_CHAR

Introduction

In this page you can find the example usage for org.apache.lucene.util UnicodeUtil MAX_UTF8_BYTES_PER_CHAR.

Prototype

int MAX_UTF8_BYTES_PER_CHAR

To view the source code for org.apache.lucene.util UnicodeUtil MAX_UTF8_BYTES_PER_CHAR.

Click Source Link

Document

Maximum number of UTF8 bytes per UTF16 character.

Usage

From source file:io.crate.operation.scalar.string.LowerFunction.java

License:Apache License

@Override
public BytesRef evaluate(Input<Object>... args) {
    Object stringValue = args[0].value();
    if (stringValue == null) {
        return null;
    }/*from   w w  w .j  a va 2s.c o m*/

    BytesRef inputByteRef = BytesRefs.toBytesRef(stringValue);

    char[] ref = new char[inputByteRef.length];
    int len = UnicodeUtil.UTF8toUTF16(inputByteRef.bytes, inputByteRef.offset, inputByteRef.length, ref);
    charUtils.toLowerCase(ref, 0, len);

    byte[] res = new byte[UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR * len];
    len = UnicodeUtil.UTF16toUTF8(ref, 0, len, res);
    return new BytesRef(res, 0, len);
}

From source file:io.crate.operation.scalar.string.UpperFunction.java

License:Apache License

@Override
public BytesRef evaluate(Input<Object>... args) {
    Object stringValue = args[0].value();
    if (stringValue == null) {
        return null;
    }// www . jav a  2  s  .  c  om

    BytesRef inputByteRef = BytesRefs.toBytesRef(stringValue);

    char[] ref = new char[inputByteRef.length];
    int len = UnicodeUtil.UTF8toUTF16(inputByteRef.bytes, inputByteRef.offset, inputByteRef.length, ref);
    charUtils.toUpperCase(ref, 0, len);

    byte[] res = new byte[UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR * len];
    len = UnicodeUtil.UTF16toUTF8(ref, 0, len, res);
    return new BytesRef(res, 0, len);
}