5 ms·
I ran into sprintf's dependence on locale recently when trying to use it in a WebAssembly module. Since I was compiling for the browser, I wanted to not depend
by matheist 5y ago
I ran into sprintf's dependence on locale recently when trying to use it in a WebAssembly module. Since I was compiling for the browser, I wanted to not depend on locale. Even setting aside the locale stuff, the wasi sdk still wanted to pull in file-related things like read/write/seek. I just wanted to do formatted print to a pre-existing buffer.
I ended up using nanoprintf — it's a single header file and in the public domain.
(https://github.com/charlesnicholson/nanoprintf https://github.com/charlesnicholson/nanoprintf)
- matheist 5y agoP.S.: musl's sprintf is the one that I noticed pulling in file APIs, via vfprintf. Maybe other libc's implement sprintf without using the file API.