parsing a UTF-8 string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

parsing a UTF-8 string

Post by jasongr »

Hello people

I have a question regarding the correct manner in which a UTF-8 string should be parsed
I have a UTF-8 string of the format:
<ch1>,<ch2>,<ch3>,<ch4>
Where <c1>...<c4> are characters in a given language
These characters could be in:
- English
- French
- Hebrew
- Spanish
and so on
Any Latin Language should work
I need to be able to parse this string into an array

I thought about using function explode and using the , as a separator
but I was wondering whether that function will be safe for the UTF-8 string
This is because I cannot assume that each character will take a single byte

any ideas?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

explode() doesn't care about the number of bytes in each element it generates. :?
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

Post by jasongr »

thanks for the tip
Post Reply