This commit is contained in:
Itxaso Aizpurua 2022-10-08 00:11:53 +02:00
parent 680f3e2097
commit 2498175ac0
1 changed files with 9 additions and 0 deletions

View File

@ -241,6 +241,15 @@ def _diff_text(left: str, right: str, verbose: int = 0) -> List[str]:
explanation: List[str] = []
# if both are strings are truthy and normalize to the same string, but we're here,
# their byte representation is different. We convert to utf-8 and compare them as bytes.
if left and right and normalize("NFD", left) == normalize("NFD", right):
return [
"Strings are different but normalize to the same string. Comparing their utf-8 encoding.",
*_compare_eq_sequence(left.encode(), right.encode()),
]
if verbose < 1:
i = 0 # just in case left or right has zero length
for i in range(min(len(left), len(right))):