18static const string roman_ones[10] = {
"",
"i",
"ii",
"iii",
"iv",
19 "v",
"vi",
"vii",
"viii",
"ix"};
20static const string roman_tens[10] = {
"",
"x",
"xx",
"xxx",
"xl",
21 "l",
"lx",
"lxx",
"lxxx",
"xc"};
23 "d",
"dc",
"dcc",
"dccc",
"cm"};
28static const string chars_han[10]= {
"?",
"一",
"二",
"三",
"四",
29 "五",
"六",
"七",
"八",
"九"};
35 if (
nr == 0)
return "o";
36 if (
nr > 3999 ||
nr < -3999)
return "?";
131 if (
nr == 0)
return "零";
132 if (
nr == 0x80000000)
return "负二十一亿四千七百四十八万三千六百四十八";
134 if (
nr >= 100000000) {
195 intptr_t i= (intptr_t)
ptr;
215 int i, n=
N (s),
res= 0;
216 if ((n > 0) && (s[0] ==
'-'))
return -
from_hex (s (1, n));
217 for (i= 0; i < n; i++) {
220 if ((s[i] >=
'A') && (s[i] <=
'F'))
res+= (int) (s[i] + 10 -
'A');
221 if ((s[i] >=
'a') && (s[i] <=
'f'))
res+= (int) (s[i] + 10 -
'a');
236template <
unsigned int cur,
typename T>
240 if constexpr (
cur > 0) {
314 string res ((
int) (
N (
bin) * 2));
316 for (
unsigned char ch :
bin) {
string locase_all(string s)
Converts all uppercase characters in a string to lowercase.
string upcase_all(string s)
Converts all lowercase characters in a string to uppercase.
#define TM_FAILED(msg)
Macro used to throw an exception with a specified error message.
The list class represents a linked list.
list(T item)
Construct a new list object with a single item.
string binary_to_hexadecimal(string bin)
Converts a binary stream to its hexadecimal represention.
string uint32_to_Hex(uint32_t i)
Converts an unsigned integer to a hexadecimal string.
std::enable_if_t< std::conjunction_v< std::is_integral< T >, std::is_unsigned< T > >, void > to_Hex_positive(T i, string &s)
Handle positive number separately to avoid unnecessary check of sign. string is passed into the funct...
string to_hanzi(int32_t nr)
Generates a Chinese numeral for a given integer.
string to_roman(int32_t nr)
Generates a Roman numeral string for an integer.
string as_hexadecimal(int i, int len)
Converts an unsigned integer to a hexadecimal string with a fixed length.
static const string roman_thousands[4]
static const string roman_ones[10]
string hanzi_sub(int16_t nr, bool leading_zero)
static const string roman_tens[10]
string to_padded_hex(uint8_t i)
Converts an 8-bit unsigned integer to a fixed-length (2) hex string.
string to_Roman(int32_t nr)
Generates an uppercase Roman numeral string for an integer.
static const string chars_han[10]
static const string roman_hundreds[10]
static const char * hex_string
int from_hex(string s)
Converts a hexadecimal string to an integer.
string to_padded_Hex(uint8_t i)
std::enable_if_t< std::conjunction_v< std::is_integral< T >, std::is_unsigned< T > >, void > as_hexadecimal_sub(T i, string &s)
Handle positive number separately to avoid unnecessary check of sign. string is passed into the funct...
string as_string(int16_t i)