# ICU4C MF2 formatToParts Suggestions Author: @sffc ## Field Categories ### UFIELD_CATEGORY_MF2 Values come from the `UMessageFormatter2Field` enum: ```cpp typedef enum UMessageFormatter2Field { UMF2_LITERAL_FIELD, UMF2_PLACEHOLDER_FIELD, UMF2_MARKUP_FIELD, UMF2_ERROR_FIELD, } UMessageFormatter2Field; ``` ### UFIELD_CATEGORY_MF2_MARKUP Values are indices into a data structure containing detail on the markup items, stored in the `MessageFormatter`. After parsing the message, the `MessageFormatter` should contain a vector of the markup items present in the message. ### UFIELD_CATEGORY_MF2_PLACEHOLDER Values are indices into a data structure containing detail on the placeholders, of the `MessageFormatter`. After parsing the message, the `MessageFormatter` should contain a vector of the placeholders present in the message. ## Example Message string: `Hello{#icon}, {#b}{$user}{/b} {$id :integer}!` The `MessageFormatter` should contain the following structure (using JSON to illustrate): ```json { "markup": [ { "name": "icon", "isPaired": false }, { "name": "b", "isPaired": true } ], "placeholders": [ { "name": "user", "type": "string" }, { "name": "id", "type": "integer" } ] } ``` Then, the fields in the `FormattedMessage` should be (when interpolating "Shane" and the number 1): ``` Hello, Shane 1! |....|....|....| 0 5 10 15 ``` | Start | Limit | Key | Value | |---|---|---|---| | 0 | 7 | UFIELD_CATEGORY_MF2 | UMF2_LITERAL_FIELD | | 5 | 5 | UFIELD_CATEGORY_MF2 | UMF2_MARKUP_FIELD | | 5 | 5 | UFIELD_CATEGORY_MF2_MARKUP | 0 | | 7 | 12 | UFIELD_CATEGORY_MF2 | UMF2_PLACEHOLDER_FIELD | | 7 | 12 | UFIELD_CATEGORY_MF2_MARKUP | 1 | | 7 | 12 | UFIELD_CATEGORY_MF2_PLACEHOLDER | 0 | | 12 | 13 | UFIELD_CATEGORY_MF2 | UMF2_LITERAL_FIELD | | 13 | 14 | UFIELD_CATEGORY_MF2 | UMF2_PLACEHOLDER_FIELD | | 13 | 14 | UFIELD_CATEGORY_MF2_PLACEHOLDER | 1 | | 13 | 14 | UFIELD_CATEGORY_NUMBER | UNUM_INTEGER_FIELD | Open question: Unclear whether there should be 1 or 2 literal fields at the start of the string (0-7 or 0-5, 5-7).