The starter code is a cleaned up version from the videos:
The task for this week is to fill in the function bytes_for(char* unicode, unsigned int n)
.
That function should take a UTF-8 string and a character count, and return the number of bytes in that UTF-8 string taken up by the first n
characters.
Examples:
bytes_for("José", 3) -> 3
bytes_for("Ülo", 3) -> 4
bytes_for("José", 4) -> 5
bytes_for("成龙", 1) -> 3
bytes_for("成龙", 2) -> 6
bytes_for("成龙", 3) -> -1
Feel free to share questions and comments about this on the Discord!
Avoid posting full solutions just to make sure folks can figure it out on their own if they want. Do feel free to show posts with incomplete code or code with errors/surprising behavior, though!