String formatting

From Amiga Development Wiki
Revision as of 04:43, 9 July 2015 by AmigaDeveloper (Talk | contribs) (Created page with "== RawDoFmt == Text formatting is similar to sprintf() but integer types default to 16-bit integers! {| class="wikitable" ! Type ! Description |- | b | BSTR |- | c, lc | Cha...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

RawDoFmt

Text formatting is similar to sprintf() but integer types default to 16-bit integers!

Type Description
b BSTR
c, lc Character
d, ld Decimal
u, lu Unsigned decimal
s String
x, lx Hexadecimal

RawDoFmt() has no support for floats.

Usage:

STATIC CONST ULONG StuffChar[] = { 0x16c04e75 };
ULONG array[] = { (ULONG)"Hello world!" };
TEXT buf[200];
 
RawDoFmt("Print: %s\n", &array, (void (*)(void))&StuffChar, buf);

NewRawDoFmt

NewRawDoFmt() replaces old RawDoFmt() with proper varargs interface. The output is not compatible with RawDoFmt(), for example, integers default to 32-bits and hexadecimal output is in lower case. In RawDoFmt() it is in upper case. Floats are supported.

Usage:

TEXT buf[200];
 
NewRawDoFmt("Print: %s\n", NULL, buf, "Hello world!");

SNPrintf

SNPrintf() provides localized string formatting and buffer length checking.

Usage:

TEXT buf[200];
 
SNPrintf(locale, "Print: %s\n", buf, sizeof(buf), "Hello world!");