Codec for Cookie-Jar files.

Format is described in TAOUP: Raymond, E., "The Art of Unix Programming", 2003, isbn:0-13-142901-9. An online version is available at: http://www.catb.org/~esr/writings/taoup/html/ch05s02.html

The cookie jar format uses % to separate records. Each record is a just a value - a bag of text.

The fortune application uses the cookie jar format:

A day for firm decisions!!!!!  Or is it?
%
A few hours grace before the madness begins again.
%
A gift of a flower will soon be made to you.

Usage

See the example in example/main.dart.

The cookieJar.decode and cookieJar.encode functions are the primary entry points (much like json.decode and json.encode).

import 'package:betto_codec_cookiejar/betto_codec_cookiejar.dart'
    show cookieJar;

const input = """A day for firm decisions!!!!!  Or is it?
%
A few hours grace before the madness begins again.
%
A gift of a flower will soon be made to you.%% with a comment
""";

void main() {
  final decoded = cookieJar.decode(input);

  print('Decoded: \n');
  for (final (i, entry) in decoded.indexed) {
    print('Entry #$i: $entry');
  }

  print('---');
  final encoded = cookieJar.encode(decoded);
  print('Encoded: \n\n$encoded');

  print('---');
  print('Re-decoded: \n');
  for (final (i, entry) in cookieJar.decode(encoded).indexed) {
    print('Entry #$i: $entry');
  }
  print('---');
}

Libraries

betto_codec_cookiejar
Codec for Cookie-Jar files.