east_asian_width 1.0.1 copy "east_asian_width: ^1.0.1" to clipboard
east_asian_width: ^1.0.1 copied to clipboard

A lightweight library for detecting East Asian Width of Unicode characters. Useful for text layout and alignment.

example/east_asian_width_example.dart

import 'package:east_asian_width/east_asian_width.dart' as eaw;

void main() {
  // Example using functions
  print(eaw.eastAsianWidth('₩').abbrev); // 'F'
  print(eaw.eastAsianWidth('。').abbrev); // 'H'
  print(eaw.eastAsianWidth('뀀').abbrev); // 'W'
  print(eaw.eastAsianWidth('a').abbrev); // 'Na'
  print(eaw.eastAsianWidth('①').abbrev); // 'A'
  print(eaw.eastAsianWidth('ف').abbrev); // 'N'

  print(eaw.characterLength('₩')); // 2
  print(eaw.characterLength('。')); // 1
  print(eaw.characterLength('뀀')); // 2
  print(eaw.characterLength('a')); // 1
  print(eaw.characterLength('①')); // 2
  print(eaw.characterLength('ف')); // 1

  print(eaw.length('あいうえお')); // 10
  print(eaw.length('abcdefg')); // 7
  print(eaw.length('¢₩。ᅵㄅ뀀¢⟭a⊙①بف')); // 19

  // Example using extension
  print('₩'.eastAsianWidth.abbrev); // 'F'
  print('。'.eastAsianWidth.abbrev); // 'H'
  print('뀀'.eastAsianWidth.abbrev); // 'W'
  print('a'.eastAsianWidth.abbrev); // 'Na'
  print('①'.eastAsianWidth.abbrev); // 'A'
  print('ف'.eastAsianWidth.abbrev); // 'N'

  print('₩'.eawCharacterLength); // 2
  print('。'.eawCharacterLength); // 1
  print('뀀'.eawCharacterLength); // 2
  print('a'.eawCharacterLength); // 1
  print('①'.eawCharacterLength); // 2
  print('ف'.eawCharacterLength); // 1

  print('あいうえお'.eawLength); // 10
  print('abcdefg'.eawLength); // 7
  print('¢₩。ᅵㄅ뀀¢⟭a⊙①بف'.eawLength); // 19
}
0
likes
160
pub points
19%
popularity

Publisher

verified publishermarinvitlov.com

A lightweight library for detecting East Asian Width of Unicode characters. Useful for text layout and alignment.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on east_asian_width