DIY: UTF-8 Validation
Explore UTF-8 encoding validation through a coding exercise focused on verifying the correctness of byte sequences. Learn to implement a function that determines if a given array of integers represents a valid UTF-8 encoded string. This lesson helps you understand the byte structure rules of UTF-8 encoding used in cybersecurity.
We'll cover the following...
We'll cover the following...
Problem description
Given an integer array data, return whether it is a valid UTF-8 encoding.
A character in UTF8 can be from 1 to 4 bytes long, subject to the following rules:
- For a
1byte character, the first bit of the packet is0, followed by its Unicode code. - For an
n-bytescharacter, the first