com.yahoo.text.Utf8类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中com.yahoo.text.Utf8类的一些代码示例,展示了Utf8类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utf8类的具体详情如下:
包路径:com.yahoo.text.Utf8
类名称:Utf8

Utf8介绍

[英]utility class with functions for handling UTF-8
[中]具有处理UTF-8函数的实用程序类

代码示例

代码示例来源:origin: com.yahoo.vespa/vespajlib

/**
 * This will construct a utf8 backing of the given string.
 * @param str The string that will be utf8 encoded
 */
public Utf8String(String str) {
  super(Utf8.toBytes(str));
  s = str;
}

代码示例来源:origin: com.yahoo.vespa/vespajlib

public static String decode(byte[] data, int pos, int len) {
  return Utf8.toString(data, pos, len);
}
public static byte[] encode(String str) {

代码示例来源:origin: com.yahoo.vespa/application

static Charset charset(String contentType) {
  if (contentType != null) {
    Matcher matcher = charsetPattern.matcher(contentType);
    if (matcher.find()) {
      try {
        return Charset.forName(matcher.group(1));
      } catch (UnsupportedCharsetException uce) {
        return Utf8.getCharset();
      }
    }
  }
  return Utf8.getCharset();
}

代码示例来源:origin: com.yahoo.vespa/vespajlib

/**
 * Utility method as toString(byte[]).
 *
 * @param data
 *            bytes to decode
 * @param offset
 *            index of first byte to decode
 * @param length
 *            number of bytes to decode
 * @return String decoded from UTF-8
 */
public static String toString(byte[] data, int offset, int length) {
  String s = toStringAscii(data, offset, length);
  return s != null ? s : toString(ByteBuffer.wrap(data, offset, length));
}

代码示例来源:origin: com.yahoo.vespa/document

buf.get(stringArray);
value.setUnChecked(Utf8.toString(stringArray));
    stringPositions = calculateStringPositions(stringArray);

代码示例来源:origin: com.yahoo.vespa/vespajlib

/**
 * Count the number of bytes needed to represent a given sequence of 16-bit
 * char values as a UTF-8 encoded array. This method is written to be cheap
 * to invoke.
 *
 * Note: It is strongly assumed to character sequence is valid.
 */
public static int byteCount(CharSequence str) { return byteCount(str, 0, str.length()); }

代码示例来源:origin: com.yahoo.vespa/document

buf.get(stringArray);
value.setUnChecked(Utf8.toString(stringArray));
    stringPositions = calculateStringPositions(stringArray);

代码示例来源:origin: com.yahoo.vespa/documentapi

public int getSerializedSize() {
  int size = 0;
  if (docId != null) {
    size += Utf8.byteCount(docId.toString()) + 1;
  }
  size += GlobalId.LENGTH;
  size += 8;
  size += 1;
  return size;
}

代码示例来源:origin: com.yahoo.vespa/container-search

/** Utility method for turning a string into utf-8 bytes */
protected static final byte[] getBytes(String string) {
  return Utf8.toBytes(string);
}
public static void putString(String s, ByteBuffer buffer) {

代码示例来源:origin: com.yahoo.vespa/container-search

public Entry(byte[] k, byte[] v) {
    key = Utf8.toString(k);
    val = Utf8.toString(v);
  }
};

代码示例来源:origin: com.yahoo.vespa/linguistics

@Override
public Detection detect(String input, Hint hint) {
  return new Detection(guessLanguage(input), Utf8.getCharset().name(), false);
}

代码示例来源:origin: com.yahoo.vespa/vespajlib

public LowercaseIdentifier(String s) {
  this(Utf8.toBytes(s));
}
public LowercaseIdentifier(AbstractUtf8Array utf8) {

代码示例来源:origin: com.yahoo.vespa/vespalog

/**
 * return the current state as a string
 * (directly fetched from the file via the mapping buffer)
 **/
public String getOnOffString() {
  byte[] levels = new byte[4 * VespaLevelControllerRepo.numLevels];
  for (int i = 0; i < levels.length; i++) {
    levels[i] = mapBuf.get(offset + i);
  }
  return Utf8.toString(levels);
}

代码示例来源:origin: com.yahoo.vespa/linguistics

@Override
public Detection detect(String input, Hint hint) {
  return new Detection(guessLanguage(input), Utf8.getCharset().name(), false);
}

代码示例来源:origin: com.yahoo.vespa/vespajlib

public Identifier(String s) {
  this(Utf8.toBytes(s));
}
public Identifier(AbstractUtf8Array utf8) {

代码示例来源:origin: com.yahoo.vespa/container-search

public void decodeBody(ByteBuffer buffer) {
  errorCode = buffer.getInt();
  errmsgLen = buffer.getInt();
  byte[] tmp = new byte[errmsgLen];
  buffer.get(tmp);
  message = Utf8.toString(tmp);
}

代码示例来源:origin: com.yahoo.vespa/config-application-package

if (!path.exists()) return;
if (fullPathNames) {
  digest.update(path.getPath().getBytes(Utf8.getCharset()));
} else {
  digest.update(path.getName().getBytes(Utf8.getCharset()));

代码示例来源:origin: com.yahoo.vespa/vespajlib

public static byte[] encode(String str) {
    return Utf8.toBytes(str);
  }
}

代码示例来源:origin: com.yahoo.vespa/linguistics

private Language guessLanguage(byte[] buf, int offset, int length) {
  return guessLanguage(Utf8.toString(buf, offset, length));
}

代码示例来源:origin: com.yahoo.vespa/linguistics

return Utf8.getCharset().name();
} else if (!hasHighs) {
  return "US-ASCII";

相关文章

微信公众号

最新文章

更多