Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 43KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. # printj
  2. Extended `sprintf` implementation (for the browser and nodejs). Emphasis on
  3. compliance, performance and IE6+ support.
  4. ```js
  5. PRINTJ.sprintf("Hello %s!", "World");
  6. ```
  7. A self-contained specification of the printf format string is included below in [this README](#printf-format-string-specification), as well as a summary of the
  8. [support against various printf implementations](#support-summary)
  9. ## Installation
  10. With [npm](https://www.npmjs.org/package/printj):
  11. ```bash
  12. $ npm install printj
  13. ```
  14. In the browser:
  15. ```html
  16. <script src="printj.js"></script>
  17. ```
  18. The browser exposes a variable `PRINTJ`
  19. When installed globally, npm installs a script `printj` that renders the format
  20. string with the given arguments. Running the script with `-h` displays help.
  21. The script will manipulate `module.exports` if available (e.g. in a CommonJS
  22. `require` context). This is not always desirable. To prevent the behavior,
  23. define `DO_NOT_EXPORT_PRINTJ`
  24. ## Usage
  25. In all cases, the relevant function takes a format and arguments to be rendered.
  26. The return value is a JS string.
  27. - `PRINTJ.sprintf(format, ...args)` assumes the arguments are passed directly
  28. - `PRINTJ.vsprintf(format, argv)` assumes the arguments are passed in an array
  29. For example:
  30. ```js
  31. > // var PRINTJ = require('printj'); // uncomment this line if in node
  32. > var sprintf = PRINTJ.sprintf, vsprintf = PRINTJ.vsprintf;
  33. > sprintf("Hello %s", "SheetJS") // 'Hello SheetJS'
  34. > sprintf("%d + %d = %d", 2,3,2+3) // '2 + 3 = 5'
  35. > vsprintf("%d + %d = %d", [2,3,5]) // '2 + 3 = 5'
  36. > sprintf("%1$02hhx %1$u %1$i %1$o", -69) // 'bb 4294967227 -69 37777777673'
  37. ```
  38. The command line script takes a format and arguments:
  39. ```
  40. usage: printj [options] <format> [args...]
  41. Options:
  42. -h, --help output usage information
  43. -d, --dump print debug information about format string
  44. Arguments are treated as strings unless prefaced by a type indicator:
  45. n:<integer> call parseInt (ex. n:3 -> 3)
  46. f:<float> call parseFloat (ex. f:3.1 -> 3.1)
  47. b:<boolean> false when lowercase value is "FALSE" or "0", else true
  48. s:<string> interpret as string (ex. s:n:3 -> "n:3")
  49. j:<JSON> interpret as an object using JSON.parse
  50. e:<JS> evaluate argument (ex. e:1+1 -> 2, e:"1"+1 -> "11")
  51. samples:
  52. $ printj '|%02hhx%d|' n:50 e:0x7B # |32123|
  53. $ printj '|%2$d + %3$d is %1$d|' e:1+2 n:1 n:2 # |1 + 2 is 3|
  54. $ printj '|%s is %s|' s:1+2 e:1+2 # |1+2 is 3|
  55. $ printj '|%c %c|' s:69 n:69 # |6 E|
  56. ```
  57. ## Testing
  58. `make test` will run the nodejs-based test.
  59. `make stress` will run a larger test encompassing every possible conversion. It
  60. requires access to a C compiler.
  61. ## License
  62. Please consult the attached LICENSE file for details. All rights not explicitly
  63. granted by the Apache 2.0 license are reserved by the Original Author.
  64. ## Badges
  65. [![Build Status](https://saucelabs.com/browser-matrix/printj.svg)](https://saucelabs.com/u/printj)
  66. [![Build Status](https://travis-ci.org/SheetJS/printj.svg?branch=master)](https://travis-ci.org/SheetJS/printj)
  67. [![Coverage Status](http://img.shields.io/coveralls/SheetJS/printj/master.svg)](https://coveralls.io/r/SheetJS/printj?branch=master)
  68. [![NPM Downloads](https://img.shields.io/npm/dt/printj.svg)](https://npmjs.org/package/printj)
  69. [![Dependencies Status](https://david-dm.org/sheetjs/printj/status.svg)](https://david-dm.org/sheetjs/printj)
  70. [![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/printj)](https://ghit.me/repo/sheetjs/printj)
  71. [![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/printj?pixel)](https://github.com/SheetJS/printj)
  72. # printf format string specification
  73. The `printf` family of functions attempt to generate and output a string of
  74. characters from a series of arguments, following a user-supplied "format string"
  75. specification. The format string contains normal characters that are written to
  76. the output string as well as specifiers that describe which parameter to insert
  77. and how to render the parameter. This specification describes how a conformant
  78. implementation should process the format string and generate an output string.
  79. Any discrepancies between this document and the reference implementation are
  80. considered bugs in the implementation.
  81. ### Original C Interface
  82. Every function in the `printf` family follows the same logic to generate strings
  83. but have different interfaces reflecting different input and output behaviors.
  84. Some functions have wide variants that use wide `wchar_t *` strings rather than
  85. normal C `char *`. The following variants are required by the POSIX spec:
  86. | function | max length | output destination | vintage | wide ver |
  87. |------------|------------|-----------------------|---------|------------|
  88. | `printf` | unbounded | standard output | K&R | `wprintf` |
  89. | `fprintf` | unbounded | stream (`FILE *`) | K&R | `fwprintf` |
  90. | `sprintf` | unbounded | string (`char *`) | K&R | `swprintf` |
  91. | `snprintf` | parameter | string (`char *`) | C99 | |
  92. | `dprintf` | unbounded | POSIX file descriptor | POSIX | |
  93. Each function has a dual function, whose name begins with `v`, that accepts the
  94. parameters as a `va_list` rather than formal parameters. In all cases, they
  95. return the number of characters written or a negative value to indicate error:
  96. ```C
  97. int sprintf(char *ostr, const char *fmt, ...);
  98. int vsprintf(char *ostr, const char *fmt, va_list arg_list);
  99. int swprintf(wchar_t *ostr, const wchar_t *fmt, ...);
  100. int vswprintf(wchar_t *ostr, const wchar_t *fmt, va_list arg_list);
  101. ```
  102. ### JS and C strings
  103. C "strings" are really just arrays of numbers. An external code page (such as
  104. ASCII) maps those numbers to characters. K&R defines two types of strings:
  105. basic character set strings (`char *`) and extended character set strings
  106. (`wchar_t *`). In contrast, JS has a true string value type.
  107. Unlike in C, JS strings do not treat the null character as an end-of-string
  108. marker. As a result, characters beyond the first null character will be used.
  109. The JS equivalent of a C extended string would be an array of the individual
  110. character codes. The C basic string equivalent would involve specifying a code
  111. page and mapping back. The `codepage` JS library supports common codepages.
  112. While capturing the essence of C strings, using arrays of character codes is not
  113. idiomatic JS. Few developers leverage this and the downsides far exceed the
  114. benefits of a more direct translation. The effect can be feigned, as shown in
  115. the `js2c` code sample at the end of the document.
  116. ### JS Interface
  117. In the absence of a standard output or even a standard concept of a stream, the
  118. non-string outputs are irrelevant. Similarly there is no JS analogue of wide
  119. characters. While useful, lack of direct memory management obviates `snprintf`.
  120. This implementation exports the remaining functions, `sprintf` and `vsprintf`.
  121. Instead of replicating the original C signature and `errno`, functions directly
  122. return the output string and throw Errors:
  123. ```typescript
  124. function sprintf(fmt:string, ...args):string;
  125. function vsprintf(fmt:string, args:Array<any>):string;
  126. ```
  127. The C functions return the number of characters written to the string, which is
  128. directly accessible in JS via the `length` property. A direct replica of the
  129. various string functions are included at the end of the document.
  130. ## Specifier heritage and regular expression
  131. Note: The regular expressions follow perl `/x` style. Whitespace characters
  132. outside of character classes are ignored. `#` is a comment character and every
  133. character until the end of the line is ignored. To convert to a standard regex:
  134. ```js
  135. regex_string.replace(/#.*$/gm,"").replace(/^\s*/gm,"").replace(/\s*\n/gm,"");
  136. ```
  137. Based on K&R, conversions originally followed the format:
  138. - required: leading `%`
  139. - optional: `-` (POSIX refers to this as the "flags")
  140. - optional: positive number or `*` (POSIX "width")
  141. - optional: period followed by positive number or `*` (POSIX "precision")
  142. - optional: an `h` or `l` to indicate size of data (POSIX "length")
  143. - required: character describing output behavior (POSIX "conversion specifier")
  144. This is captured by the regular expression:
  145. ```perl
  146. /%(?:
  147. ([-])? # flags (only minus sign)
  148. (\d+|\*)? # width
  149. (?:\.(\d+|\*))? # period + precision
  150. ([hl])? # length
  151. ([dioxXucsfeEgGp%]) # conversion specifier
  152. )/x
  153. ```
  154. Various implementations of `printf` have added different functionality.
  155. ANSI standards up through C99:
  156. - more flags `"+"` `" "` `"0"` `"#"`
  157. - more lengths `"L"` `"hh"` `"ll"` `"j"` `"z"` `"t"`
  158. - more conversions `"F"` `"a"` `"A"` `"n"`
  159. The POSIX specification of `printf` added:
  160. - positional parameters to identify argument indices
  161. - more flags `"'"`
  162. - more conversions `"C"` `"S"`
  163. - clarifications regarding corner cases and "undefined behavior"
  164. BSD implementations added:
  165. - more lengths `"q"`
  166. - more conversions `"D"` `"U"` `"O"`
  167. glibc (GNU) added:
  168. - more lengths `"Z"`
  169. - more conversions `"m"`
  170. Windows C Runtime (CRT) added:
  171. - more lengths `"I"` `"I32"` `"I64"` `"w"`
  172. glibc and CRT both added `Z`. glibc uses `Z` for the length `size_t`. CRT uses
  173. `Z` as a conversion for length-prefixed strings. This implementation takes the
  174. former approach, handling `Z` in the same way as `z`.
  175. BSD and IBM C library both added `D`. BSD uses `D` as a conversion, namely as
  176. an alias of `ld`. IBM uses `D` for the length for `_Decimal64`, a decimal
  177. floating point type, in accordance with ISO/IEC TR 24732. This implementation
  178. takes the former approach.
  179. This implementation also adds new conversions:
  180. - `"b"` and `"B"` for binary (base-2) integer renderings
  181. - `"y"` and `"Y"` for true/false and yes/no Boolean conversions
  182. - `"J"` for JSON
  183. - `"T"` and `"V"` for JS typeof and valueOf inspection
  184. Combining the various extensions yields the following regular expression:
  185. ```perl
  186. /%(?:
  187. %| # literal %% (flags etc prohibited)
  188. ([1-9]\d*\$)? # positional parameter
  189. ([-+ 0\x23\x27]*)? # flags
  190. ([1-9]\d*|\*(?:[1-9]\d*\$)?)? # width
  191. (?:\.(\d+|\*(?:[1-9]\d*\$)?))? # precision
  192. (hh?|ll?|[LzjtqZIw])? # length
  193. ([diouxXfFeEgGaAcCsSpnDUOmbByYJVT]) # conversion specifier
  194. )/x
  195. ```
  196. This implementation explicitly does not support certain non-standard extensions:
  197. - AltiVec vector length extensions (`v` with `h`/`l`/`ll`):
  198. - CRT fixed width lengths `I32` and `I64`
  199. ## Conversion Specifier Quick Reference Table
  200. | C | Type | Summary |
  201. |-----|:--------:|-------------------------------------------------------------|
  202. | `a` | floating | base-2 exp form w/ hex mantissa and dec exponent, lowercase |
  203. | `A` | floating | base-2 exp form w/ hex mantissa and dec exponent, uppercase |
  204. | `b` | extended | cast to C `unsigned int`, standard form binary |
  205. | `B` | extended | cast to C `unsigned long`, standard form binary |
  206. | `c` | text | print `latin-1` char from number OR first char of string |
  207. | `C` | text | print `UCS-2` char from number OR first char of string |
  208. | `d` | integral | cast to C `int`, standard form decimal |
  209. | `D` | integral | cast to C `long`, standard form decimal |
  210. | `e` | floating | base-10 exp form w/dec mantissa and dec exponent, lowercase |
  211. | `E` | floating | base-10 exp form w/dec mantissa and dec exponent, uppercase |
  212. | `f` | floating | base-10 decimal form, lowercase extended values |
  213. | `F` | floating | base-10 decimal form, uppercase extended values |
  214. | `g` | floating | print using `e` or `f` conversion based on value/precision |
  215. | `G` | floating | print using `E` or `F` conversion based on value/precision |
  216. | `i` | integral | cast to C `int`, standard form decimal (alias of `d`) |
  217. | `J` | extended | prints objects using JSON or `util.inspect` |
  218. | `m` | misc | prints info about Error objects (JS equivalent of `errno`) |
  219. | `n` | misc | do not print! stores number of chars written to arg `.len` |
  220. | `o` | integral | cast to C `unsigned int`, standard form octal |
  221. | `O` | integral | cast to C `unsigned long`, standard form octal |
  222. | `p` | misc | print `"l"` field of object (fake pointer) |
  223. | `s` | text | print string argument |
  224. | `S` | text | print string argument (alias of `"s"`) |
  225. | `T` | extended | print type information (`typeof` or `Object toString`) |
  226. | `u` | integral | cast to C `unsigned int`, standard form decimal |
  227. | `U` | integral | cast to C `unsigned long`, standard form decimal |
  228. | `V` | extended | print primitive value (`valueOf`) |
  229. | `x` | integral | cast to C `unsigned int`, standard form hex, lowercase |
  230. | `X` | integral | cast to C `unsigned long`, standard form hex, uppercase |
  231. | `y` | extended | prints `true`/`false` or `yes`/`no` based on Boolean value |
  232. | `Y` | extended | prints `TRUE`/`FALSE` or `YES`/`NO` based on Boolean value |
  233. | `%` | misc | print the literal `%` character |
  234. ## Parameter Selection
  235. The default behavior is to consume arguments in order:
  236. ```C
  237. printf("Count to 3: %d %d %d", 1, 2, 3); // Count to 3: 1 2 3
  238. ```
  239. POSIX `printf` permits explicit argument selection, bypassing the standard
  240. behavior of using the arguments in order. To select the `n`-th argument, use
  241. `n$` immediately after the `%` token to select an argument for the conversion:
  242. ```C
  243. printf("%d %d %d", 1, 2, 3); // 1 2 3 (implicit order 1, 2, 3 )
  244. printf("%1$s %2$s %3$s", "a", "b", "c"); // a b c (explicit order 1, 2, 3 )
  245. printf("%1$s %3$s %2$s", "a", "b", "c"); // a c b (explicit order 1, 3, 2 )
  246. ```
  247. The POSIX standard asserts that mixing positional and non-positional conversions
  248. is undefined behavior. This implementation handles mixing by tracking the index
  249. for non-positional conversions:
  250. ```C
  251. printf("%s %4$s %s %5$s %s", "a", "b", "c", "d", "e"); // a d b e c
  252. ```
  253. The POSIX standard requires that if an argument is used in the format, every
  254. preceding argument must be used. This implementation relaxes that requirement:
  255. ```C
  256. printf("%3$s", "a", "b", "c"); // c (technically invalid since "a"/"b" unused)
  257. ```
  258. ## Dynamic Specifiers
  259. The width and precision specifiers may include the dynamic specifier `*` which
  260. instructs the engine to read the next argument (assumed to be an integer). Just
  261. as with the positional parameter, `idx$` immediately after the `*` token selects
  262. the numeric argument.
  263. For example:
  264. ```C
  265. printf("|%5s|", "sheetjs"); // |sheetjs| (width = 5)
  266. printf("|%*s|", 5, "sheetjs"); // |sheetjs| (width first argument)
  267. printf("|%2$*1$s|", 5, "sheetjs", 10); // |sheetjs| (width is argument #1)
  268. printf("|%10s|", "sheetjs"); // | sheetjs| (width = 10)
  269. printf("|%2$*3$s|", 5, "sheetjs", 10); // | sheetjs| (width is argument #3)
  270. ```
  271. Arguments are generally consumed in order as presented in the format string:
  272. ```C
  273. printf("|%s|", val);
  274. printf("|%*s|", width, val);
  275. printf("|%.*s|", prec, val);
  276. printf("|%*.*s|", width, prec, val);
  277. printf("|%0*.*d|", 4, 2, 1); // | 01| width=4 prec=2 value=1
  278. ```
  279. Positional arguments can be applied to width and precision:
  280. ```C
  281. printf("|%*.*d|", width, prec, val);
  282. printf("|%2$0*3$.*1$d|", prec, val, width);
  283. printf("|%0*.*d|", 4, 2, 1); // | 01| width=4 prec=2 value=1 flags='0'
  284. printf("|%1$0*3$.*2$d|", 1, 2, 4); // | 01| width=4 prec=2 value=1 flags='0'
  285. ```
  286. A negative width is interpreted as the `-` flag with a positive width:
  287. ```C
  288. printf("|%*.*d|", 4, 2, 1); // | 01| width=4 prec=2 value=1 flags=''
  289. printf("|%-*.*d|", 4, 2, 1); // |01 | width=4 prec=2 value=1 flags='-'
  290. printf("|%*.*d|", -4, 2, 1); // |01 | width=4 prec=2 value=1 flags='-'
  291. printf("|%-*.*d|", -4, 2, 1); // |01 | width=4 prec=2 value=1 flags='-'
  292. ```
  293. A negative precision is discarded:
  294. ```C
  295. printf("|%*s|", 4, "sheetjs"); // |sheetjs| width=4
  296. printf("|%*.*s|", 4, 3, "sheetjs"); // | she| width=4 prec=3
  297. printf("|%*.*s|", 4, 2, "sheetjs"); // | sh| width=4 prec=2
  298. printf("|%*.*s|", 4, 1, "sheetjs"); // | s| width=4 prec=1
  299. printf("|%*.*s|", 4, 0, "sheetjs"); // | | width=4 prec=0
  300. printf("|%*.*s|", 4, -1, "sheetjs"); // |sheetjs| width=4 (prec ignored)
  301. ```
  302. # C Data Model
  303. JS has one numeric type `Number` which represents an IEEE754 double-precision
  304. (64-bit) floating point number. C has a multitude of numeric types, including
  305. floating point as well as integer types. The sizes of those data types are
  306. implementation-dependent. A "C data model" specifies the sizes of the core C
  307. data types.
  308. ### Integer Types
  309. POSIX `printf` specification references 8 integer types in integer conversions:
  310. | C data type | fmt | unsigned type | fmt | signed type | fmt |
  311. |-------------|------:|----------------------|------:|---------------|------:|
  312. | `char` | | `unsigned char` | `hhu` | `signed char` | `hhd` |
  313. | `short` | `hd` | `unsigned short` | `hu` | | |
  314. | `int` | `d` | `unsigned int` | `u` | | |
  315. | `long` | `ld` | `unsigned long` | `lu` | | |
  316. | `long long` | `lld` | `unsigned long long` | `llu` | | |
  317. | `size_t` | `zu` | | | `ssize_t` | `zd` |
  318. | `intmax_t` | `jd` | `uintmax_t` | `ju` | | |
  319. | `ptrdiff_t` | `td` | | | | |
  320. C99 does not officially define a signed `size_t` or unsigned `ptrdiff_t` type.
  321. POSIX does define `ssize_t` but no equivalent `uptrdiff_t`.
  322. BSD additionally recognizes the types `quad_t` and `u_quad_t`, which this
  323. implementation treats as `long long int` and `unsigned long long int`.
  324. ### Character and String Types
  325. Two integer types are used in character and string conversions:
  326. | type | fmt |
  327. |-------------|------:|
  328. | `wchar_t` | `ls` |
  329. | `wint_t` | `lc` |
  330. Both wide types `wchar_t` and `wint_t` can be signed or unsigned according to
  331. C99. Both types are used only in character and string conversions. Based on
  332. K&R "printable characters are always positive", the types are assumed unsigned.
  333. ### Floating Point Number Types
  334. K&R recognizes 3 floating point types. C99 later tied it to IEC 60559:
  335. | C data type | precision | total bits | exponent | mantissa | fmt |
  336. |:--------------|:----------|:----------:|:--------:|:--------:|------:|
  337. | `float` | single | `32` | `8` | `23` | |
  338. | `double` | double | `64` | `11` | `52` | `f` |
  339. | `long double` | extended | `80` | `15` | `64` | `Lf` |
  340. ## Implementation
  341. Numerous "C data models", specifying the bit/byte sizes of the various types,
  342. have been and continue to be used. For example, OSX and other modern 64-bit
  343. UNIX flavors use the "LP64" C data model. 64-bit Windows currently uses the
  344. "LLP64" model. 32-bit systems generally use the "ILP32" model. The 8-bit byte
  345. sizes for the various types under the various models are defined in ctypes.json
  346. in the `Models` object as per the following table:
  347. | type | ctypes.json | LP64 | ILP32 | LLP64 |
  348. |-------------|-------------|-----:|------:|------:|
  349. | `char` | `char` | 1 | 1 | 1 |
  350. | `short` | `short` | 2 | 2 | 2 |
  351. | `int` | `int` | 4 | 4 | 4 |
  352. | `long` | `long` | 8 | 4 | 4 |
  353. | `long long` | `longlong` | 8 | 8 | 8 |
  354. | `wchar_t` | `wchar_t` | 4 | 4 | 2 |
  355. | `wint_t` | `wint_t` | 4 | 4 | 2 |
  356. | `size_t` | `size_t` | 8 | 4 | 8 |
  357. | `intmax_t` | `intmax_t` | 8 | 8 | 8 |
  358. | `ptrdiff_t` | `ptrdiff_t` | 8 | 4 | 8 |
  359. By default the source assumes the LP64 data model. Other data models are
  360. supported in the source tree, controlled by the JSFLAGS variable in the build
  361. process. Set the `JS_MODEL` variable to the desired index as specified in the
  362. `ModelNames` array in `bits/ctype.json`:
  363. ```bash
  364. $ <bits/ctypes.json jq -r '.ModelNames|.[]' # LP64 ILP32 LLP64
  365. $ JSFLAGS=-DJS_MODEL=0 make # LP64
  366. $ JSFLAGS=-DJS_MODEL=1 make # ILP32
  367. $ JSFLAGS=-DJS_MODEL=2 make # LLP64
  368. ```
  369. To create a custom model, add the spec to `bits/ctypes.json` by appending the
  370. model name to the end of the `ModelNames` array and adding an entry to the
  371. `Models` object. The current models are defined as follows:
  372. ```json
  373. {
  374. "ModelNames":["LP64", "ILP32", "LLP64"],
  375. "Models": {
  376. "LP64": { "char":1, "short":2, "int":4, "long":8, "longlong":8, "wint_t":4, "wchar_t":4, "size_t":8, "intmax_t":8, "ptrdiff_t":8 },
  377. "ILP32": { "char":1, "short":2, "int":4, "long":4, "longlong":8, "wint_t":4, "wchar_t":4, "size_t":4, "intmax_t":8, "ptrdiff_t":4 },
  378. "LLP64": { "char":1, "short":2, "int":4, "long":4, "longlong":8, "wint_t":2, "wchar_t":2, "size_t":8, "intmax_t":8, "ptrdiff_t":8 }
  379. }
  380. }
  381. ```
  382. # Integer Conversions
  383. This section covers the conversions `diouxXDUO`. The base-2 conversions `bB`
  384. are an extension and are discussed at the end, but the same basic rules apply.
  385. JS has one Number type (representing an IEEE754 8-byte floating point number)
  386. that is capable of representing a 32-bit integer. It cannot represent the full
  387. range of 64-bit integers exactly. Care is taken to avoid operations that may
  388. inadvertently result in a conversion to a smaller integral type.
  389. ## Restricting Integer Values
  390. JS Bitwise operations convert numbers to 32-bit integers before performing
  391. operations. With the exception of the unsigned right shift operator `>>>`, all
  392. operations act on signed integers. For example:
  393. ```js
  394. Math.pow(2,31) | 0; // -2147483648 == -Math.pow(2,31)
  395. (Math.pow(2,32)-2) ^ 0; // -2
  396. -1 >>> 0 // 4294967295 == Math.pow(2,32) - 1
  397. ```
  398. JS Number can exactly represent every integer in the range `-2^53 .. 2^53`. For
  399. lengths exceeding 32 bits, `Math.round` is appropriate.
  400. | bits | unsigned | signed |
  401. |------|---------------------------|-------------------------------------------|
  402. | 8 | `V & 0xFF` | `V &= 0xFF; if(V > 0x7F) V-= 0x100` |
  403. | 16 | `V & 0xFFFF` | `V &= 0xFFFF; if(V > 0x7FFF) V-= 0x10000` |
  404. | 32 | `V >>> 0` | `V | 0` |
  405. | 64 | `Math.abs(Math.round(V))` | `Math.round(V)` |
  406. ## Length Specifiers for Integer Conversions
  407. When a length specifier implies a certain size (such as `hh` for a single-byte
  408. integer), the number will be converted before rendering strings. For example:
  409. ```C
  410. printf("%1$02hhx %1$02hx %1$02lx %1$02llx", 256); // |00 100 100 100|
  411. printf("%1$02hhx %1$02hx %1$02lx %1$02llx", 4096); // |00 1000 1000 1000|
  412. printf("%1$02hhx %1$02hx %1$02lx %1$02llx", 65536); // |00 00 10000 10000|
  413. ```
  414. Values are restricted by first limiting the result to a specified number of
  415. bytes (appropriate bit-and) and then adding or subtracting to ensure the value
  416. is signed or unsigned according to the conversion specifier. If a length is
  417. specified, it overrides the implied length of the conversion. The following
  418. table describes the behavior of this implementation:
  419. | implied C type | ctypes.json | length | conv default |
  420. |:------------------------------------|:------------|:------:|:-------------|
  421. | `int` or `unsigned int` | `int` | (none) | d i o u x X |
  422. | `char` or `unsigned char` | `char` | hh |
  423. | `short` or `unsigned short` | `short` | h |
  424. | `long` or `unsigned long` | `long` | l | D U O |
  425. | `long long` or `unsigned long long` | `longlong` | L ll q |
  426. | `intmax_t` or `uintmax_t` | `intmax_t` | j |
  427. | `size_t` or `ssize_t` | `size_t` | z Z |
  428. | `ptrdiff_t` or unsigned variant | `ptrdiff_t` | t |
  429. ## Rendering Unsigned Integers in Base 10 ("u" and "U" conversions)
  430. `num.toString(10)` produces the correct result for exact integers.
  431. `"u"` conversion restricts values to `int`; `"U"` restricts to `long`.
  432. ## Rendering Unsigned Integers in Base 8 ("o" and "O" conversions)
  433. Even though `num.toString(8)` is implementation-dependent, all browser
  434. implementations use standard form for integers in the exact range.
  435. The alternate form (`#`) prints a `"0"` prefix.
  436. `"o"` conversion restricts values to `int`; `"O"` restricts to `long`.
  437. ## Rendering Unsigned Integers in Base 16 ("x" and "X" conversions)
  438. Even though `num.toString(16)` is implementation-dependent, all browser
  439. implementations use standard form for integers in the exact range.
  440. The alternate form (`#`) prints a `"0x"` or `"0X"` prefix.
  441. Unlike `"U" "O" "D"`, `"X"` conversion uses `A-F` instead of `a-f` in hex.
  442. ## Rendering Signed Integers in Base 10 ("d" "i" and "D" conversions)
  443. `num.toString(10)` produces the correct result for exact integers. The flags
  444. `" +"` control prefixes for positive integers.
  445. `"di"` conversions restrict values to `int`; `"D"` restricts to `long`.
  446. # Floating Point Conversions
  447. This section covers the conversions `fFeEgGaA`.
  448. Due to C variadic argument promotion rules, `float` types are always promoted to
  449. `double`. None of the conversions or length specifiers signal that an argument
  450. is to be interpreted as a `float`. There is no JS canonical representation of
  451. an extended floating point number, so JS `Number` suffices.
  452. ## Infinity, NaN, and Negative Zero
  453. JS recognizes a few special IEEE754 values, as described in the following table:
  454. | JS value | JS Expression | Description |
  455. |------------:|:--------------|:-----------------------------------------------|
  456. | `Infinity` | `1./0.` | Positive limiting value `lim{x->0+} 1/x` |
  457. | `-Infinity` | `-1./0.` | Negative limiting value `lim{x->0+} -1/x` |
  458. | `NaN` | `0./0.` | Placeholder for "not-a-number" e.g. `0./0.` |
  459. | `-0.` | `-1/Infinity` | Negative limiting value `lim{x->0-} x` |
  460. JS `Number` methods render different strings from the POSIX spec:
  461. | JS value | POSIX string | JS string |
  462. |------------:|:----------------------------------------------|--------------:|
  463. | `Infinity` | `"inf" "INF"` or `"infinity" "INFINITY"` | `"Infinity"` |
  464. | `-Infinity` | `"-inf" "-INF"` or `"-infinity" "-INFINITY"` | `"-Infinity"` |
  465. | `NaN` | `"[-]nan" "[-]NAN"` w/opt parenthesized chars | `"NaN"` |
  466. | `-0.` | uses negative sign (e.g. `"-0"` under `"%f"`) | same as `+0.` |
  467. This implementation performs the required adjustments.
  468. ## Exponential Form ("e" and "E" conversions)
  469. Aside from the special cases discussed above, JS `num.toExponential(prec)`
  470. differs from POSIX `printf("%1$.*2$e", num, prec)` in the exponent field: JS
  471. writes exponents with the fewest digits (POSIX requires 2+ digits). This is
  472. easily fixed by inspecting the output string and inserting a "0" when needed.
  473. The optional `#` flag forces the decimal point to appear when precision is 0.
  474. This is also easily corrected by adding a decimal point just before the "e".
  475. ## Standard Form ("f" and "F" conversions)
  476. The POSIX spec only requires that the number of digits after the decimal point
  477. is equal to the precision. It does not specify how many digits appear before
  478. the decimal point, nor does it specify how to handle numbers that cannot be
  479. exactly represented.
  480. For values less than `1e21` the JS `num.toFixed(n)` generally matches `%f` with
  481. the specified precision. However, for larger values `toFixed` defaults to the
  482. exponential form.
  483. ## Value-dependent Form ("g" and "G" conversions)
  484. The final form (exponential or standard) is determined based on the value. The
  485. threshold is different from the JS `toString` / `toPrecision` thresholds and
  486. depends on the specified precision as well as the base-10 exponent:
  487. | Value | `"%.3g"` | `toPrecision(3)` |
  488. |----------:|:-----------|:-----------------|
  489. | 1.2345e-4 | `0.000123` | `0.000123` |
  490. | 1.2345e-5 | `1.23e-05` | `0.0000123` |
  491. | 1.2345e-6 | `1.23e-06` | `0.00000123` |
  492. | 1.2345e-7 | `1.23e-07` | `1.23e-7` |
  493. According to JS spec, `toPrecision` uses standard form when `precision > E` and
  494. `E >= -6`. For printf standard form is used when `precision > E` and `E >= -4`.
  495. ## Hex-Mantissa Decimal-Binary-Exponent Form ("a" and "A" conversions)
  496. A general exponential form involves 3 parameters: radix of the mantissa, base of
  497. the exponent expression, and radix of the exponent expression. The standard
  498. exponential form uses decimal for all three parts. For base 16, there are quite
  499. a few reasonable combinations. Consider the value `1.234567e-80`:
  500. | Mant | Exp Base | Radix-10 (sigil `";"`) | Radix-16 (sigil `";"`) |
  501. |:----:|:--------:|:-----------------------|:-----------------------|
  502. | 10 | 10 | `1.234567;-80` | `1.234567;-50` |
  503. | 16 | 10 | `1.3c0c9539b8887;-80` | `1.3c0c9539b8887;-50` |
  504. | 16 | 16 | `5.daf8c8f5f4104;-67` | `5.daf8c8f5f4104;-43` |
  505. | 16 | 4 | `1.76be323d7d041;-133` | `1.76be323d7d041;-85` |
  506. | 16 | 2 | `1.76be323d7d041;-266` | `1.76be323d7d041;-10a` |
  507. POSIX `"%a"` uses a hex mantissa (16), decimal exponent radix (10), and binary
  508. exponent base (2). The general normalized form requires that the integral part
  509. of the mantissa to exceed 0 and not to exceed `exponent base - 1` except in the
  510. special case of `0`. The sigil is `p` and exponent sign is always used.
  511. JS `num.toString(radix)` is implementation-dependent for valid non-10 radices
  512. (`2-9, 11-36`). IE uses hex-mantissa decimal-hex-exponent form when the
  513. absolute value of the base-2 exponent exceeds 60. Otherwise, IE uses an exact
  514. standard hexadecimal form. Chrome, Safari and other browsers always use the
  515. exact standard hexadecimal form. Both forms are easily converted to `"%a"` by
  516. calculating and dividing by the appropriate power of 2.
  517. For each non-zero normal floating point value, there are 4 acceptable strings
  518. that represent the value, derived by multiplying the normalized value by powers
  519. of 2 and adjusting the exponent accordingly:
  520. | Value | Normalized | Alternate `*2` | Alternate `*4` | Alternate `*8` |
  521. |:--------|:---------------|:---------------|:---------------|:---------------|
  522. | `1` | `1p+0` | `2p-1` | `4p-2` | `8p-3` |
  523. | `.2` | `1.9999999p-3` | `3.3333333p-4` | `6.6666666p-5` | `c.cccccccp-6` |
  524. | `.69` | `1.6147ae1p-1` | `2.c28f5c2p-2` | `5.851eb85p-3` | `b.0a3d70ap-4` |
  525. | `6.e20` | `1.043561p+69` | `2.086ac3p+68` | `4.10d586p+67` | `8.21ab0dp+66` |
  526. JS engines follow the glibc model: multiply by a suitable power of 16 so that
  527. the mantissa is between 1 and 16, render left to right one digit at a time, then
  528. fix the result at the end. FreeBSD and OSX always show the normalized form.
  529. This implementation defaults to the normalized form. To switch to the glibc
  530. form, define `DO_NOT_NORMALIZE` in the `JSFLAGS` variable when building:
  531. ```bash
  532. $ JSFLAGS=-DDO_NOT_NORMALIZE make
  533. ```
  534. # Character Conversions
  535. This section covers the conversions `sScC`.
  536. ## Rendering Strings ("s" and "S" conversions)
  537. JS has no concept of "wide strings" (`wchar_t *` in C), so the length modifiers
  538. are ignored. `s` and `S` are treated as equivalent.
  539. Arguments are first interpreted as strings by calling the `String` function.
  540. Implementing `toString` on the argument to be converted may lead to unexpected
  541. results:
  542. ```C
  543. var O = {valueOf:function() {return 456;}, toString:function() {return "123"}};
  544. printf("%1$s %1$d", O); // "123 456"
  545. ```
  546. If a positive precision is specified, up to that many characters will be taken
  547. from the string. Otherwise the entire string will be used:
  548. ```C
  549. printf("|%s|", "sheetjs"); // '|sheetjs|' (no precision)
  550. printf("|%.9s|", "sheetjs"); // '|sheetjs|' (string shorter than precision)
  551. printf("|%.5s|", "sheetjs"); // '|sheet|' (string truncated)
  552. ```
  553. Lengths are measured using the JS string length accessor. Since there is no
  554. attempt to correct for multi-character sequences like combining marks, the
  555. results may be unexpected:
  556. ```C
  557. printf("%.1s","ñ"); // 'n' not "ñ"
  558. ```
  559. If the width is specified and is greater than the width of the string to be
  560. rendered, padding will be applied. If the `"-"` flag is specified, then the
  561. string will be right-padded, otherwise it will be left-padded. If the `"0"`
  562. flag is specified, the final string is left-padded with zeroes. The `"-"` flag
  563. takes precedence over `0`.
  564. ```C
  565. printf( "|%s|", "sheetjs"); // '|sheetjs|' (no width)
  566. printf( "|%5s|", "sheetjs"); // '|sheetjs|' (string longer than width)
  567. printf( "|%9s|", "sheetjs"); // '| sheetjs|' (no flag = left pad spaces)
  568. printf( "|%09s|", "sheetjs"); // '|00sheetjs|' ("0" = left pad "0")
  569. printf( "|%-9s|", "sheetjs"); // '|sheetjs |' ("-" = right pad space)
  570. printf("|%-09s|", "sheetjs"); // '|sheetjs |' ("0" ignored)
  571. ```
  572. ## Rendering Characters ("c" and "C" conversions)
  573. JS has no concept of "wide characters" (`wchar_t` in C). The length modifier is
  574. used in determining whether the number should be interpreted as one or two
  575. 16-bit character codes (when the "C" format or the "l" or "ll" specifiers are
  576. used) or a single 8-bit char code. Precision and flags are ignored.
  577. # Non-Numeric Conversions
  578. ## The literal "%" symbol ("%" conversion)
  579. All other parameters are ignored.
  580. ## Interpreting and Rendering Pointers ("p" conversion)
  581. JS has no true concept of pointers. In array and typed array contexts, it is
  582. common to associate a position object that stores the address relative to the
  583. start of the array. This implementation reads the `l` key and interprets as a
  584. 32-bit or 52-bit unsigned integer depending on `size_t` in the data model.
  585. The normal output format is equivalent to `"%#x"` but the alternate form emits
  586. using the `"%d"` format. When the pointer is invalid, `-1` is rendered. Only
  587. the `"#"` flag is interpreted.
  588. ```js
  589. var x = {}, y = {l:3};
  590. printf("%1$p %1$#p", y); // 0x3 3
  591. printf("%1$p %1$#p", x); // 0xFFFFFFFF -1
  592. ```
  593. ## Extracting length of a partial conversion ("n" conversion)
  594. C `printf` permits a special `n` conversion which interprets the argument as an
  595. integral pointer (interpreted size controlled by the length specifier) and
  596. writes the number of characters printed to that pointer.
  597. JS has no true concept of pointers in the C sense. The library works around
  598. the limitation by interpreting the argument as an object and assigning to the
  599. `len` key. The conversion does not write any characters to the output string:
  600. ```js
  601. var x = {};
  602. printf("%1$s %2$J%2$n abc", "foo", x); // "foo {} abc", also sets x.len = 6
  603. // |........| |......| (6 chars at that point)
  604. ```
  605. This implementation mutates the object while processing:
  606. ```js
  607. var x = {};
  608. printf("%1$s %2$J%2$n %3$s %2$J", "foo", x, "bar"); // 'foo {} bar {"len":6}'
  609. ```
  610. ## Error messages ("m" conversion)
  611. glibc supports an `m` conversion that does not consume arguments. It renders
  612. the string `strerror(errno)` where `strerror` is the libc function and `errno`
  613. is the global error number.
  614. JS has no equivalent of `errno` and no standard JS runtime exposes a similar
  615. global error variable, so `%m` will write the default message `"Success"`. A
  616. positional parameter or `#` flag changes the behavior:
  617. | form | position | behavior |
  618. |:------------:|:--------:|---------------------------------------|
  619. | main | no | do not read argument, emit "Success" |
  620. | alt (flag #) | no | read and process next argument |
  621. | main or alt | yes | read and process specified argument |
  622. In all forms other than `"%m"`, an argument will be processed as follows:
  623. - If the argument is not an instance of an `Error`, emit "Success"
  624. - If the `message` field is set, emit the error message.
  625. - If the `errno` field is set, emit "Error number " followed by the errno
  626. - Otherwise emit "Error " followed by the error interpreted as a String
  627. ```
  628. var x = new Error("sheetjs");
  629. x.errno = 69; x.toString = function() { return "SHEETJS"; };
  630. printf("|%#m|", x); // |sheetjs|
  631. delete x.message;
  632. printf("|%#m|", x); // |Error number 69|
  633. delete x.errno;
  634. printf("|%#m|", x); // |Error SHEETJS|
  635. ```
  636. # Extensions
  637. These additional conversions take advantage of unused format characters:
  638. ## Rendering Boolean Values ("y" and "Y" conversions)
  639. Values are converted to Boolean and tested for truthiness. The `Y` rendering
  640. is the uppercase version of the equivalent rendering with format `y`.
  641. | form | truthy value `y` (`Y`) | falsy value `y` (`Y`) |
  642. |:------------:|:-----------------------:|:---------------------:|
  643. | main | `true` (`TRUE`) | `false` (`FALSE`) |
  644. | alt (flag #) | `yes` (`YES`) | `no` (`NO`) |
  645. Width and precision are applied in the same manner as the `s` conversion.
  646. ```js
  647. printf("|%1$y|%2$Y|%1$#Y|%2$#y|%2$.1y|", 1, 0); // |true|FALSE|YES|no|f|
  648. printf("|%05.2Y|%-5.2y|", 1, 0); // |000TR|fa |
  649. ```
  650. ## Rendering JSON ("J" conversion)
  651. The default rendering is the standard output from `JSON.stringify`. Alternate
  652. form (`"#"` flag) renders using `util.inspect` if available.
  653. ```js
  654. var x = {
  655. a: [1,[2,3,4],5,6,7],
  656. b: {
  657. c: {
  658. d: { e:"f" },
  659. g:"h",
  660. i:"j"
  661. },
  662. k:"l",
  663. m:"n",
  664. o:"p"},
  665. q: "r"
  666. };
  667. printf("%J", x) // '{"a":[1,[2,3,4],5,6,7],"b":{"c":{"d":{"e":"f"}, ..(ctnd)..
  668. printf("%#J", x) // '{ a: [ 1, [ 2, 3, 4 ], 5, 6, 7 ],\n b: { c: { ..(ctnd)..
  669. ```
  670. Width, precision and other flags are ignored.
  671. ## JS typeof and valueOf ("T" and "V" conversion)
  672. Under the "T" conversion, the result of `typeof arg` is rendered. If the `#`
  673. flag is specified, the type is derived from `Object.prototype.toString`:
  674. ```
  675. printf("%1$T %1$#T", 1); // 'number Number'
  676. printf("%1$T %1$#T", 'foo'); // 'string String'
  677. printf("%1$T %1$#T", [1,2,3]); // 'object Array'
  678. printf("%1$T %1$#T", null); // 'object Null'
  679. printf("%1$T %1$#T", undefined); // 'undefined Undefined'
  680. ```
  681. Under the "V" conversion, the result of `arg.valueOf()` is rendered:
  682. ```
  683. var _f = function() { return "f"; };
  684. var _3 = function() { return 3; };
  685. printf("%1$d %1$s %1$V", {toString:_f}); // '0 f f'
  686. printf("%1$d %1$s %1$V", {valueOf:_3}); // '3 [object Object] 3'
  687. printf("%1$d %1$s %1$V", {valueOf:_3, toString:_f}); // '3 f 3'
  688. ```
  689. ## Rendering Unsigned Integers in Base 2 ("b" and "B" conversions)
  690. The implementation is similar to the octal `"o"` and `"O"` conversions, except
  691. for the radix (2 for `"b"` and `"B"`) and the alternate-form prefix (`"0b"`)
  692. # Miscellaneous Notes
  693. ## Format Characters
  694. For compatibility purposes, format characters must be printable ASCII characters
  695. (ASCII codes `0x20 - 0x7E`). The 95 eligible characters are listed below:
  696. | C | Type | C | Type | C | Type | C | Type |
  697. |-----|:----------:|-----|:----------:|-----|:----------:|-----|:----------:|
  698. | `a` | conversion | `A` | conversion | ` ` | flag | `!` | |
  699. | `b` | conversion | `B` | conversion | `"` | | `#` | flag |
  700. | `c` | conversion | `C` | conversion | `$` | other | `%` | conversion |
  701. | `d` | conversion | `D` | conversion | `&` | | `'` | flag |
  702. | `e` | conversion | `E` | conversion | `(` | | `)` | |
  703. | `f` | conversion | `F` | conversion | `*` | other | `+` | flag |
  704. | `g` | conversion | `G` | conversion | `,` | | `-` | flag |
  705. | `h` | length | `H` | | `.` | other | `/` | |
  706. | `i` | conversion | `I` | length | `0` | digit | `1` | digit |
  707. | `j` | length | `J` | conversion | `2` | digit | `3` | digit |
  708. | `k` | | `K` | | `4` | digit | `5` | digit |
  709. | `l` | length | `L` | length | `6` | digit | `7` | digit |
  710. | `m` | conversion | `M` | | `8` | digit | `9` | digit |
  711. | `n` | conversion | `N` | | `:` | | `;` | |
  712. | `o` | conversion | `O` | conversion | `<` | | `=` | |
  713. | `p` | conversion | `P` | | `>` | | `?` | |
  714. | `q` | length | `Q` | | `@` | | `[` | |
  715. | `r` | | `R` | | `\` | | `]` | |
  716. | `s` | conversion | `S` | conversion | `^` | | `_` | |
  717. | `t` | length | `T` | conversion | `~` | | `{` | |
  718. | `u` | conversion | `U` | conversion | `|` | | `}` | |
  719. | `v` | | `V` | conversion | `` ` `` | |
  720. | `w` | length | `W` | |
  721. | `x` | conversion | `X` | conversion |
  722. | `y` | conversion | `Y` | conversion |
  723. | `z` | length | `Z` | length |
  724. ## JS and C strings
  725. C provides no guidance on the actual character set. According to K&R all valid
  726. characters in source code must be in a character set that is a subset of the
  727. 7-bit ASCII set. This implementation falls back on the UTF-16 base required by
  728. JS. When converting C literal strings, there are a few differences in escaping:
  729. | C escape sequence | Equivalent JS | Notes |
  730. |:------------------|:--------------|:---------------------------------------|
  731. | `"\a"` | `"\007"` | BEL character will not ring in browser |
  732. | `"\?"` | `"?"` | JS does not handle trigraphs |
  733. | `"\ooo"` (octal) | `"\ooo"` | JS uses Latin-1 for non-ASCII codes |
  734. | `"\xhh"` (hex) | `"\xhh"` | JS uses Latin-1 for non-ASCII codes |
  735. ## Browser Deviations
  736. Opera does not always include the last significant digit in base 16 rendering.
  737. For example, `(-6.9e-11).toString(16)` is `"0.000000004bddc5fd160168"` in every
  738. other browser but is `"0.000000004bddc5fd16017"` in Opera. The test suite skips
  739. the `%a/%A` precision-less formats in Opera.
  740. `Object.prototype.toString.call` gives unexpected results in older browsers, and
  741. no attempt is made to correct for them. The test suite ignores those cases:
  742. | value | `%#T` expected | `%#T` IE < 9 | `%#T` Android < 4.4 |
  743. |:------------|:---------------|:-------------|:--------------------|
  744. | `null` | `"Null"` | `"Object"` | `"global"` |
  745. | `undefined` | `"Undefined"` | `"Object"` | `"global"` |
  746. ## Support Summary
  747. - Full [POSIX](http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html) conversion support with extensions!
  748. [Conversion Specifier Table](#conversion-specifier-quick-reference-table)
  749. - Full support for POSIX flags and positional parameters
  750. - Emulation of BSD `quad_t` and `u_quad_t` conversion
  751. - Parser accepts but does not emulate CRT wide and unicode character conversions
  752. - glibc `Z` length conversion and extended `m` error support
  753. - Parser fails on CRT `I32`/`I64` fixed lengths
  754. - Default `LP64` data model but can be configured to support `ILP32` or `LLP64`