]> khamidou — GitHub mirrors - arcanist.git/commit
Compute UTF8 string differences correctly, accounting for combining characters
authorepriestley <git@epriestley.com>
Thu, 23 May 2013 21:38:09 +0000 (14:38 -0700)
committerepriestley <git@epriestley.com>
Thu, 23 May 2013 21:38:09 +0000 (14:38 -0700)
commit1fcf7bac4eb47d2e940b423a033daf8a696f493e
tree5fc1898d4fdb07e262dab19f35d6dd09a5dfd3d1
parent24d54a5fbd17b302fd17d861a325ce5d75bef84c
Compute UTF8 string differences correctly, accounting for combining characters

Summary:
@Afaque_Hussain has done a bunch of utf8 work here; combined with PhutilEditDistanceMatrix we can now do utf8 diffs correctly, in a general way, without a significant performance impact.

Use PhutilEditDistanceMatrix and `phutil_utf8v_combined()` to compute accurate diffs for all (or, at least, most) UTF8 text.

The only thing this doesn't handle completely correctly is lines beginning with combining characters. This is messy/expensive to handle and will probably never actually happen, so I'm punting for now. Nothing should actually break.

The utf8 stuff will be slow, but we only pay for it when we need it.

Test Plan:
Ran unit tests. I changed a few unit tests to use a non-combining character (snowman) for clarity, and some results are different now (since we get combining characters right).

{F44064}

Reviewers: btrahan, Afaque_Hussain

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T2379

Differential Revision: https://secure.phabricator.com/D6019
src/difference/ArcanistDiffUtils.php
src/difference/__tests__/ArcanistDiffUtilsTestCase.php