Skip to content

AndreasMager/dart-sprintf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dart-sprintf

Dart implementation of sprintf.

Build Status

Getting Started

Add the following to your pubspec.yaml:

dependencies:
  sprintf: ">=1.0.9 <2.0.0"

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.

About

Dart implementation of sprintf

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 98.9%
  • Python 1.1%