Solution: Iterating UTF-32 Strings
Learn how to iterate UTF-32 strings at specific locations.
We'll cover the following
Problem statement
UTF-32 encodes all characters using 32 bits across four bytes. Knowing this, how can you iterate UTF-32 strings or access arbitrary characters at specific locations?
Solution
Because UTF-32 encodes strings using 32 bits across four bytes, we can access arbitrary characters by multiplying our offsets by four and then retrieving the following four bytes from the byte array.
For example, we can convert a UTF-32 encoded string into a byte array using the following sample code:
Get hands-on with 1400+ tech skills courses.