Skip to content

convertlib release

convertlib 3.7.0

  • [Breaking Changes]
    • ByteCollector.bigInt() now defaults to Endian.big, matching number(). Pass endian: Endian.little to get the old values. The top-level toBigInt still defaults to little endian.
    • The hex, octal, and UTF-8 decoders now throw a FormatException on input values outside 0..255. They used to keep only the low 8 bits, so fromUtf8([0x141]) returned "A". Use allowMalformed: true or UTF8Codec.lenient to keep the old UTF-8 behavior.
  • New codecs. Each one comes with to<Name>, from<Name>, and tryFrom<Name>, and all except Punycode and Bech32 also have to<Name>Bytes:
    • Base-36: Base36Codec with standard (lowercase) and upper. Decoding accepts either case.
    • Base-45 (RFC 9285): Base45Codec.standard.
    • Base-58: Base58Codec with the Bitcoin (standard), Flickr (flickr), and Ripple (ripple) alphabets.
    • Base-62: Base62Codec with standard (0-9A-Za-z) and lowerFirst (0-9a-zA-Z).
    • Base-85: Base85Codec with Ascii85 (standard), Z85 (z85), the git alphabet (git), and the RFC 1924 IPv6 form (ipv6).
    • Bech32 (BIP-173) and Bech32m (BIP-350): Bech32Codec with bech32, bech32m, and lightning (no 90-character limit), decoding to Bech32Data. SegWit addresses get SegwitCodec, SegwitAddress, toSegwitAddress, fromSegwitAddress, and tryFromSegwitAddress.
    • Percent-encoding (RFC 3986): PercentCodec with standard (unreserved characters only), component (like Uri.encodeComponent), form (like Uri.encodeQueryComponent, with + for a space), and PercentCodec.custom for your own set of unreserved characters. Unlike Uri, it encodes any bytes, not only UTF-8.
    • Punycode (RFC 3492): PunycodeCodec with standard, and domain for the xn-- labels of internationalized domain names.
  • Base-36, Base-58, and Base-62 write each leading zero byte as the alphabet's first character (0, or 1 in Bitcoin Base-58), so leading zeros survive a roundtrip.
  • Export the RadixEncoder and RadixDecoder base classes, which convert bytes to and from any radix up to 255. Base-36, Base-58, and Base-62 are built on them.
  • Add the Base64Codec.imap alphabet (A-Za-z0-9+,, not padded), the modified Base-64 of IMAP mailbox names (RFC 3501).
  • Add base36(), base45(), base58(), base62(), base85(), and bech32(hrp) to ByteCollector.
  • Add allowMalformed to fromUtf8, tryFromUtf8, and ByteCollector.utf8(), and the UTF8Codec.lenient codec. They clip out-of-range values and decode ill-formed UTF-8 to U+FFFD, as dart:convert does, instead of throwing.
  • ByteCollector.utf8() now decodes with fromUtf8 instead of dart:convert. It accepts and rejects the same bytes, but its error messages now name the failing byte and its position.
  • UTF8Decoder.decode now accepts any List<int>.
  • Fix fromHex accepting :;<=>? as the digits A-F.
  • Fix CryptDataBuilder.build sharing its parameter map with the built CryptData, so later param calls changed the built value.
  • Speed up UTF-8 encoding and decoding on the VM, especially for ASCII text.

All posts·RSS feed