Class DecodedText

java.lang.Object
dev.frostlake.functions.scalar.encoding.DecodedText

public final class DecodedText extends Object
Decoded bytes read back as TEXT, which they are only allowed to be when they are valid UTF-8.

The _STRING decoders hand back a VARCHAR, so bytes that spell no string are an error and not a lossy conversion: live answers Invalid UTF8 detected while decoding 'qw==' — quoting the INPUT as written, not the bytes — for BASE64_DECODE_STRING and HEX_DECODE_STRING alike, while their TRY_ spellings answer NULL. Java's new String(bytes, UTF_8) silently substitutes the replacement character instead, which is how a one-byte 0xAB used to come back as a one-character string. The _BINARY decoders are unaffected: they return the bytes and never read them.

  • Method Details

    • strict

      public static String strict(byte[] bytes, String source)
      The bytes as text, refusing anything that is not valid UTF-8.
      Parameters:
      bytes - the decoded bytes
      source - the input exactly as written, for the message
      Returns:
      the decoded text
    • lenient

      public static String lenient(byte[] bytes)
      The bytes as text, or null when they are not valid UTF-8 — the TRY_ spellings' answer.
      Parameters:
      bytes - the decoded bytes
      Returns:
      the decoded text, or null