Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

ITextFormatter

The ITextFormatter interface provides functions that allow applications to format strings in a language-aware way. Applications can set the language, locale, year offset, and parameters for a specific ITextFormatter object, then call ITextFormatter_FormatText() to format a string.

Required Files
AEEITextFormatter.h

AEECTextFormatter.h

Class ID(s)
AEECLSID_CTextFormatter
Interface ID
AEEIID_ITextFormatter
Location
platform\system\inc in the Brew MP SDK

The following code snippet shows how ITextFormatter can be used to format text:

AECHAR pawFmtString[] = "Today, {5:D}, you can purchase {2,2} cans 
                                 of {1} for {3:C} or {4:C;engb}."
int dwLen = ITextFormatter_FormatText(pitf, 
                                     (pitf, 
                                      NULL, 
                                      0, 
                                      pawFmtString,
                                      "s;d;d;d;j",
                                      pszProductName,
                                      nNumCans,
                                      dwPriceDollars,
                                      dwPricePounds,
                                      date));

AECHAR *pawText = (AECHAR *)MALLOC(dwLen);

dwResult = ITextFormatter_FormatText(pitf, 
                                    (pitf, 
                                     pawText, 
                                     &dwLen, 
                                     pawFmtString,
                                     "s;d;d;d;j",
	                                    pszProductName,
	                                    nNumCans,
	                                    dwPriceDollars,
	                                    dwPricePounds,
	                                    date));

Displaying the text in pawText produces:

Today, November 10, 2004, you can purchase 12 cans of Spam for $18.95 or £10.00.