Share this page

# blazor_convert_to_formatted_ex

Decodes a raw MessagePack buffer into human-readable JSON by using an explicit input length.

## C Language

int blazor_convert_to_formatted_ex("<messagepack_buffer>", length, "TargetParam=<parameter_name>" );

Blazor - Web Functions

Argument | Description
--- | ---
messagepack_buffer | The MessagePack buffer to decode.
length | The number of bytes to decode from the input buffer, including embedded `\0` bytes.
TargetParam | The name of the parameter that stores the decoded JSON output.

## Return Values

This function stores the decoded JSON in the target parameter.

## Parameterization

You cannot use standard parameterization for this function.

## General Information

The blazor_convert_to_formatted_ex function extends blazor_convert_to_formatted by adding an explicit length parameter. This function is primarily intended for decoding literal string inputs that may contain embedded null bytes (`\0`).

Literal string inputs that contain `\0` can be problematic, because they are truncated by C-style string handling. The explicit length lets the decoder process the complete buffer, including any embedded null bytes.

For hex-escaped byte strings, the length parameter is usually unnecessary, because null bytes are represented as hex escaped characters.

The length argument is unrelated to the SignalR length prefix used inside MessagePack payloads. It just specifies how many bytes of the input buffer should be processed by the decoder.

## Examples

In the following example, the explicit length allows decoding to continue past the embedded null byte.

Copy code

    blazor_convert_to_formatted_ex("‘ªBlazor\0Web", 12, "TargetParam=FormattedValue");

    /* FormattedValue = ["Blazor\u0000Web"] */

In the following example, the length is not needed, because “`\0`” is represented as a hex escaped character. The same result can also be achieved with blazor_convert_to_formatted.

Copy code

    blazor_convert_to_formatted_ex(
        "\\x91\\xAA\\x42\\x6C\\x61\\x7A\\x6F\\x72\\x00\\x57\\x65\\x62",
        48,
        "TargetParam=FormattedValue");

    /* FormattedValue = ["Blazor\u0000Web"] */

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: