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

Method canonical

basex-core/src/main/java/org/basex/util/Strings.java:392–400  ·  view source on GitHub ↗

Canonicalizes a string: heuristic CP437/UTF-8 mojibake fix followed by Unicode normalization. @param string raw string @return canonical string

(final String string)

Source from the content-addressed store, hash-verified

390 * @return canonical string
391 */
392 public static String canonical(final String string) {
393 final byte[] bytes = string.getBytes(CP437);
394 String fixed = string;
395 if(string.equals(new String(bytes, CP437))) {
396 final String decoded = Token.string(bytes);
397 if(!contains(decoded, '\uFFFD')) fixed = decoded;
398 }
399 return Normalizer.normalize(fixed, Normalizer.Form.NFC);
400 }
401}

Callers 3

canonicalMethod · 0.95
lookupMethod · 0.95
canonicalMethod · 0.95

Calls 4

stringMethod · 0.95
containsMethod · 0.95
equalsMethod · 0.45
normalizeMethod · 0.45

Tested by 1

canonicalMethod · 0.76