A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/umsg_8h.html below:

ICU 77.1: i18n/unicode/umsg.h File Reference

C API: MessageFormat.

MessageFormat C API

MessageFormat prepares strings for display to users, with optional arguments (variables/placeholders). The arguments can occur in any order, which is necessary for translation into languages with different grammars.

The opaque UMessageFormat type is a thin C wrapper around a C++ MessageFormat. It is constructed from a pattern string with arguments in {curly braces} which will be replaced by formatted values.

Currently, the C API supports only numbered arguments.

For details about the pattern syntax and behavior, especially about the ASCII apostrophe vs. the real apostrophe (single quote) character ’ (U+2019), see the C++ MessageFormat class documentation.

Here are some examples of C API usage: Example 1:

UChar

*result, *tzID, *str;

int32_t resultLengthOut, resultlength;

str=(

UChar

*)malloc(

sizeof

(

UChar

) * (strlen(

"disturbance in force"

) +1));

u_uastrcpy

(pattern,

"On {0, date, long}, there was a {1} on planet {2,number,integer}"

);

resultlength=0;

resultlength=resultLengthOut+1;

result=(

UChar

*)realloc(result,

sizeof

(

UChar

) * resultlength);

}

printf("%s\n", austrdup(result) );

U_CAPI int32_t u_strlen(const UChar *s)

U_CAPI UCalendar * ucal_open(const UChar *zoneID, int32_t len, const char *locale, UCalendarType type, UErrorCode *status)

Open a UCalendar.

@ UCAL_TRADITIONAL

Despite the name, UCAL_TRADITIONAL designates the locale's default calendar, which may be the Gregori...

U_CAPI UDate ucal_getMillis(const UCalendar *cal, UErrorCode *status)

Get a UCalendar's current time in millis.

U_CAPI void ucal_setDateTime(UCalendar *cal, int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second, UErrorCode *status)

Set a UCalendar's current date.

void * UCalendar

A calendar.

void * UDateFormat

A date formatter.

char16_t UChar

The base type for UTF-16 code units and pointers.

U_CAPI int32_t u_formatMessage(const char *locale, const UChar *pattern, int32_t patternLength, UChar *result, int32_t resultLength, UErrorCode *status,...)

Format a message for a locale.

U_CAPI UChar * u_uastrcpy(UChar *dst, const char *src)

Copy a byte string encoded in the default codepage to a ustring.

#define NULL

Define NULL if necessary, to nullptr for C++ and to ((void *)0) for C.

UErrorCode

Standard ICU4C error code type, a substitute for exceptions.

@ U_BUFFER_OVERFLOW_ERROR

A result would not fit in the supplied buffer.

@ U_ZERO_ERROR

No error, no warning.

double UDate

Date and Time data type.

Typically, the message format will come from resources, and the arguments will be dynamically set at runtime.

Example 2:


int32_t resultlength, resultLengthOut, i;

double testArgs= { 100.0, 1.0, 0.0};

u_uastrcpy

(pattern,

"The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}"

);

for(i=0; i<3; i++){

resultlength=0;

resultlength=resultLengthOut+1;

result=(

UChar

*)malloc(

sizeof

(

UChar

) * resultlength);

}

printf("%s\n", austrdup(result) );

free(result);

}

Example 3:




int32_t resultlength,resultLengthOut;

log_verbose("Testing message format with Select test #1\n:");

u_uastrcpy

(pattern,

"{0} est {1, select, female {all\\u00E9e} other {all\\u00E9}} \\u00E0 Paris."

);

u_uastrcpy

(expected,

"Kirti est all\\u00E9e \\u00E0 Paris."

);

resultlength=0;

{

resultlength=resultLengthOut+1;

result=(

UChar

*)malloc(

sizeof

(

UChar

) * resultlength);

log_verbose("PASS: MessagFormat successful on Select test#1\n");

else{

log_err("FAIL: Error in MessageFormat on Select test#1\n GOT %s EXPECTED %s\n", austrdup(result),

austrdup(expected) );

}

free(result);

}

U_CAPI int32_t u_strcmp(const UChar *s1, const UChar *s2)

Compare two Unicode strings for bitwise equality (code unit order).

Definition in file umsg.h.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4