Anyone got a function that converts a string into bytes?
example: "Sample sentence"
would be converted to "15" bytes.
I can't think of a way right now due to a massive head ache....
Anyways thanks for any help.
stragy;10968280 wrote:example: "Sample sentence" would be converted to "15" bytes.
That may be true, if you assume that the string will always contain ASCII-encoded characters (or any other single-byte character sets), in which case you could simply use [man]strlen/man (since 1 character == 1 byte).
Otherwise, you'd want to look into using [man]mb_strwidth/man and specify the proper character encoding.
Turns out someone already made a function for this, sorry for the spam thread.
I swear Google wasn't turning out anything...