Answer the question
In order to leave comments, you need to log in
How to split a string of 16 UTF-8 characters into 32-bit PHP blocks?
Hello Dear experts, please help the student =(
I need to implement the TEA encryption algorithm in PHP.
UTF-8 string consisting of 16 characters: "1234567887654321"
How can I split it into 4 blocks of 32-bit? on Wikipedia in the SI language it is designated as " uint32_t", help please.
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
UTF-8 is not divided into bytes (only code points).
If the characters in your string can only take values from the ASCII range, then that string should be encoded to ASCII (where 1 character == 1 byte) and then split into bytes or blocks of bytes.
If non-ASCII characters (Unicode) are possible in the string, then you will have to forget about the fixed length in bytes. Such a string can take any number of bytes (depending on its content).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question