PHP-FineDiff
PHP-FineDiff copied to clipboard
Added UTF-8 support
I'm using FineDiff for a project using UTF-8, so I added basic support to it. The commit contains mb_strcspn() and mb_strspn() and a lot of reformatting, so you might only want to pull the additional functions and replace all string functions with their mb_ equivalents.
Speedwise it might be clever to create an extra UTF-8 version of the class, since the manually written mb_ functions won't be as fast as their PHP versions (and were, in fact, written to work instead of being fast).
re: private method splittochars
, why not use preg_split
instead? If I remember right, it should work with unicode.
Also worth noting, it's considered bad form by many to submit PRs from your master branch, in case you weren't aware. Most devs prefer PRs sent from feature branches.
It should with the /u flag. Feel free to use that one. I didn't do an extensive search for my helpers, I just implemented what came first to my mind. :-)
Kinda wish you'd separated the formatting into its own commit, that way I could look at just the commits that actually change stuff and see what you're doing, and see if there's any way I could help improve it at all :
E: GITHUB, STOP EATING MY BACKSLASHES. GRRRR.
Well I did the changes before even thinking about forking and sending a PR. Kinda sucks, I know, but a quick grep for 'str' should give you all the relevant positions in the code that need the 'mb_'. The additional stuff is just at the end.