b_encode_decode 1.0.3-r3 copy "b_encode_decode: ^1.0.3-r3" to clipboard
b_encode_decode: ^1.0.3-r3 copied to clipboard

A Dart library for implementing the encoding and decoding of the Bencode format.

example/b_encode_decode_example.dart

import 'dart:typed_data';

import 'package:b_encode_decode/b_encode_decode.dart' as bencode;

void main() {
  print(String.fromCharCodes(bencode.encode('string'))); // => "6:string"
  print(String.fromCharCodes(bencode.encode(123))); // => "i123e"
  print(
      String.fromCharCodes(bencode.encode(['str', 123]))); // => "l3:stri123ee"
  print(String.fromCharCodes(
      bencode.encode({'key': 'value'}))); // => "d3:key5:valuee"
  var map = bencode.decode(Uint8List.fromList('d3:key5:valuee'.codeUnits),
      stringEncoding:
          'utf-8'); // => { key: "value" } , the string value is bytes array

  print(map);
  // Special character
  var ccc = bencode.encode({'中文': 'ddd'});
  var m1 = bencode.decode(ccc);
  print(m1);
}
0
likes
0
pub points
60%
popularity

Publisher

unverified uploader

A Dart library for implementing the encoding and decoding of the Bencode format.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on b_encode_decode