random_unicode 0.2.4 copy "random_unicode: ^0.2.4" to clipboard
random_unicode: ^0.2.4 copied to clipboard

A library to generate random Unicode strings within the given range(s).

example/random_unicode_example.dart

// Copyright (c) 2022, Alexander Iurovetski
// All rights reserved under MIT license (see LICENSE file)

import 'package:random_unicode/random_unicode.dart';

/// Entry point
///
void main(List<String> args) {
  // Getting minimum and maximum string length
  // from the command-line arguments
  //
  final argCount = args.length;
  final minStrLen = (argCount <= 0 ? 100 : int.parse(args[0]));
  final maxStrLen = (argCount <= 1 ? minStrLen : int.parse(args[1]));

  // Creating the string generator
  //
  final u = RandomUnicode()
    ..addIncluded(min: 0x20, max: 0x7F)
    ..addIncluded(min: 0x100, max: 0x200)
    ..addIncluded(min: 0x1000, max: 0x2000)
    ..addExcluded(list: r'BEZbez'.codeUnits);

  // Generating the string
  //
  final str = u.string(minStrLen, maxStrLen);

  // Showing the result
  //
  print('Len: $minStrLen <= ${str.length} <= $maxStrLen\n$str');
}
0
likes
140
pub points
31%
popularity

Publisher

verified publisheraiurovet.com

A library to generate random Unicode strings within the given range(s).

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

lim

More

Packages that depend on random_unicode