Text, bytes, and Unicode

F-TEXT-V4-3hard

Fit the byte budget

A notification tool counts, previews and size-limits UTF-8 messages.

What needs to change

Repair fit so each message keeps the longest prefix of whole code points within the UTF-8 byte limit.

Reproduce

  1. Compile and run the two-budget sample with g++, then use Check work for budgets that end inside a character.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

The file contains its headers, the Request struct, readRequests and main. The browser compiles with g++ -std=c++23.

Input: a byte limit, one space, then the message. main prints size() of the kept string.

Messages are valid UTF-8 and limits are nonnegative whole numbers. Characters means code points; no normalization or grapheme-preserving cut is required.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in