termunicode 0.2.0 copy "termunicode: ^0.2.0" to clipboard
termunicode: ^0.2.0 copied to clipboard

Unicode library to get character properties (width, emoji, printable, etc)

example/termunicode_example.dart

import 'dart:io';

import 'package:termunicode/termunicode.dart';

void main() async {
  final withEsc = 'Hola \x1bmundo\x1b'.runes
      .fold(
        StringBuffer(),
        (sb, rune) => isNonPrintableCp(rune) ? (sb..write('')) : (sb..write(String.fromCharCode(rune))),
      )
      .toString();

  final strs = [
    '你好 世界',
    'hello',
    'hello 🌎',
    'hello 👋🏻',
    'hello 👩‍🔬',
    withEsc,
    'コンニチハ',
    '🇦🇷🇰🇷🇿🇲',
  ];

  stdout.writeln(' 123456789012345 ');
  for (final str in strs) {
    stdout.writeln('|${centerString(str, 15)}| => len: ${widthString(str)}');
  }
  stdout.writeln('\nversion: ${unicodeVersion()}');
}

String centerString(String str, int width) {
  final strWidth = widthString(str);
  final pad = (width - strWidth) ~/ 2;
  return ' ' * pad + str + ' ' * (width - strWidth - pad);
}
1
likes
160
points
3
downloads

Publisher

verified publishernetflux.com.ar

Weekly Downloads

Unicode library to get character properties (width, emoji, printable, etc)

Homepage
Repository (GitHub)
View/report issues

Topics

#unicode #ucd

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

characters

More

Packages that depend on termunicode