> From: "John Carroll" <or*******@yaho o.com>
Does anyone have a function or procedure for converting integers to
character strings?
Your question is hopelessly vague. There are all sorts of mappings from
integers to character strings. Here are just a few (with quote marks
omitted):
Arabic numerals:
Decimal: 42
Octal: 52
Hexadecimal: 2A
Binary: 101010
Unary with stop bit: 111111111111111 111111111111111 1111111111110
Tally:
Original: IIIII IIIII IIIII IIIII IIIII IIIII IIIII IIIII II
Old: <http://www.rawbw.com/~rem/AsciiArt/TallyOldAA.txt>
New: <http://www.rawbw.com/~rem/AsciiArt/TallyNewAA.txt>
Roman numerals:
Old: XXXXII
New: XLII
Cardinal:
English: forty-two
German: zwei und vierzig (Note: AltaVista Babelfish gets this wrong!)
French: quarante deux
Spanish: cuarenta dos
Portuguese: quarenta dois
Ordinal:
English: forty-second
French: quarante seconde
Spanish: cuarenta segundos
Portuguese: quarenta segundos
German: (Babelfish says vierzig zweites, but I don't believe it's correct.)
Traditional base 12:
English: three dozen and six
French: trois douzaines et six
German: drei Dutzend und sechs
Spanish: tres docenas y seises
Traditional by Abraham Lincoln:
English: two score and two
So do you want a single function capable of all those conversions, or what?
Oh, you just want a single character? That's not possible because the
range of integers is larger than the range allowed for a single
character, whether a single byte (US-ASCII or Latin-1) or double byte
(subset of UniCode). If you restrict the range of integers to what
will fit in a single byte, then you have your choice of Latin-1 or
several other system-dependent codes. If you restrict the range of
integers to what will fit in 7 bits, you have your choice of US-ASCII
or EBCDIC. (C provides support only for US-ASCII, via a "cast".) If you
restrict the range of integers to 0 thru 35, you have extended
IBM-hexadecimal: 0123...9ABCDE.. .XYZ. If you restrict the range to only
0 thru 15, C provides support via sprintf(&ch, "%x", intval).