sprintf 1.0.0-alpha1 copy "sprintf: ^1.0.0-alpha1" to clipboard
sprintf: ^1.0.0-alpha1 copied to clipboard

outdatedDart 1 only

Dart implementation of sprintf

dart-sprintf #

Dart implementation of sprintf.

Getting Started #

Add the following to your pubspec.yaml:

dependencies:
  sprintf:
    git: git://github.com/Naddiseo/dart-sprintf.git

then run pub install.

Next, import dart-sprintf:

#import('package:sprintf/sprintf.dart');

Example #

#import('package:sprintf/sprintf.dart');

void main() {
	print(sprintf("%04i", [-42]));
	print(sprintf("%s %s", ["Hello", "World"]));
	print(sprintf("%#04x", [10]));
}
-042
Hello World
0x0a

Limitations #

  • Negative numbers are wrapped as 64bit ints when formatted as hex or octal.

Differences to C's printf

  • When using fixed point printing of numbers with large exponents, C introduces errors after 20 decimal places. Dart-printf will just print 0s.
130
likes
0
points
3.98M
downloads

Publisher

unverified uploader

Weekly Downloads

Dart implementation of sprintf

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

unittest

More

Packages that depend on sprintf