The Apple Iconv library uses WTF-8 when UTF-8 is requested and does not
return an error for invalid UTF-32 input.
Run iconv directly in test to detect this issue and adapt the expected values.
`boost::charconv::detail::parser` is not made for parsing (large)
integers in exponential notation.
It is mainly tested for parsing floating point numbers in hexadecimal format.
Given we know ICU will output either an integer string or a number in
"E notation" (1.2E2) we can convert that rather easily to a "regular"
integer string by "moving" the dot to the right according to the
exponent. The trailing gap is filled with zeros before passing it to
`from_chars` which is now able to handle the range checks for us.
This avoids overflows that can happen when multiplying the
significant by the exponent which, due to integer arithmetic, would be
cumbersome to guard against.
Any situation that could yield a fractional or a too large value can be caught early.
ICU doesn't support uint64_t directly but provides access to formatting
and parsing of decimal number strings.
Use Boost.Charconv to interface with that.
Fixes#235
As reported in #235 formatting the first number which doesn't fit into
int64_t anymore fails to add the thousands separators.
I.e.:
`9223372036854775807` -> `9,223,372,036,854,775,807`
`9223372036854775808` -> `9223372036854775808`
Add a test reproducing that that for all backends.
A lot of checks and a major workaround are for ICU 4.8 or earlier which
can be removed.
An annoying bug (Parsing of timezones like "GMT" in "full" format followed by unrelated text)
fixed in 4.8.1 is worth avoiding by requiring this version over 4.8.0.
StringPiece is only available in 4.2+ and is required for proper parsing
and formatting.
As this version is now "old enough", just assume 4.2+ removing many
conditionals.
The Drone CI fails because the en_US.UTF-8 `locale_t` does not have a
grouping and thousand separator so "12,345" fails to parse.
Format instead to have the expected format as input.
When parsing a string like "123.456" to an integer the ICU backend would
first parse it greedily to a floating point value and then cast/truncate
it to an integer.
Set the flag to only parse integers when parsing to an integral number.
Care must be taken not to set that when parsing e.g. a currency or date
to an integer where the truncation is intended.
CI shows that MSVC calls the allocator 3 times as often as expected.
This is due to some internal structures.
Hence only count char and wchar_t allocations
Cygwin doesn't (reliably) use the actual allocator type but possibly one
obtained via `rebind` which makes all checks for e.g. `Alloc::usedId`
fail as the value stays zero.
Use a single variable in a private namespace and access it by reference.