PHP-FineDiff icon indicating copy to clipboard operation
PHP-FineDiff copied to clipboard

Added UTF-8 support

Open xrstf opened this issue 13 years ago • 4 comments

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).

xrstf avatar Dec 12 '11 00:12 xrstf

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.

katanacrimson avatar Dec 12 '11 01:12 katanacrimson

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. :-)

xrstf avatar Dec 12 '11 01:12 xrstf

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.

katanacrimson avatar Dec 12 '11 01:12 katanacrimson

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.

xrstf avatar Dec 12 '11 01:12 xrstf