charcode 1.3.1 icon indicating copy to clipboard operation
charcode: ^1.3.1 copied to clipboard

Constants for ASCII and common non-ASCII character codes. Integer constants corresponding to the code points of individual characters.

example/example.dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source is governed by a
// BSD-style license that can be found in the LICENSE file.

import "package:charcode/charcode.dart";

void main() {
  print(String.fromCharCodes([
    $E,
    $x,
    $a,
    $m,
    $p,
    $l,
    $e,
    $exclamation,
  ]));
}

/// Check whether `(` and `)` are balanced in [input].
bool checkBalancedParentheses(String input) {
  var openParenCount = 0;
  for (var i = 0; i < input.length; i++) {
    var char = input.codeUnitAt(i);
    if (char == $lparen) {
      openParenCount++;
    } else if (char == $rparen) {
      openParenCount--;
      if (openParenCount < 0) return false;
    }
  }
  return openParenCount == 0;
}
26
likes
120
pub points
99%
popularity

Publisher

verified publisher iconinfimum.dk

Constants for ASCII and common non-ASCII character codes. Integer constants corresponding to the code points of individual characters.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.BSD-3-Clause (LICENSE)

More

Packages that depend on charcode