MCPcopy Create free account
hub / github.com/BaseXdb/basex / cp

Method cp

basex-core/src/main/java/org/basex/util/Token.java:220–235  ·  view source on GitHub ↗

Returns the codepoint of a character at the specified position. Returns a replacement character for invalid values. @param token token @param pos character position @return current character

(final byte[] token, final int pos)

Source from the content-addressed store, hash-verified

218 * @return current character
219 */
220 public static int cp(final byte[] token, final int pos) {
221 // 0xxxxxxx
222 final byte b = token[pos];
223 if(b >= 0) return b;
224 // number of bytes to be read
225 final int cl = cl(b);
226 if(b < -64 || pos + cl > token.length) return REPLACEMENT;
227 // 110xxxxx 10xxxxxx
228 if(cl == 2) return (b & 0x1F) << 6 | token[pos + 1] & 0x3F;
229 // 1110xxxx 10xxxxxx 10xxxxxx
230 if(cl == 3) return (b & 0x0F) << 12 | (token[pos + 1] & 0x3F) << 6 |
231 token[pos + 2] & 0x3F;
232 // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
233 return (b & 0x07) << 18 | (token[pos + 1] & 0x3F) << 12 |
234 (token[pos + 2] & 0x3F) << 6 | token[pos + 3] & 0x3F;
235 }
236
237 /**
238 * Returns the byte length of a UTF-8 character.

Callers 15

readMethod · 0.95
getMethod · 0.95
compareMethod · 0.95
compareMethod · 0.95
forEachCpMethod · 0.95
indexOfMethod · 0.95
lastIndexOfMethod · 0.95
chopMethod · 0.95
tcMethod · 0.95
cpMethod · 0.95
stemMethod · 0.95
dbNameMethod · 0.45

Calls 1

clMethod · 0.95

Tested by

no test coverage detected