diff --git a/src/SIL.Machine/PunctuationAnalysis/QuotationMarkStringMatch.cs b/src/SIL.Machine/PunctuationAnalysis/QuotationMarkStringMatch.cs index 1dffa148..0e322ca6 100644 --- a/src/SIL.Machine/PunctuationAnalysis/QuotationMarkStringMatch.cs +++ b/src/SIL.Machine/PunctuationAnalysis/QuotationMarkStringMatch.cs @@ -75,7 +75,7 @@ public string PreviousCharacter if (previousSegment != null && !TextSegment.MarkerIsInPrecedingContext(UsfmMarkerType.Paragraph)) { return new StringInfo(previousSegment.Text).SubstringByTextElements( - previousSegment.Text.Length - 1, + StringInfo.ParseCombiningCharacters(previousSegment.Text).Length - 1, 1 ); } diff --git a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkStringMatchTests.cs b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkStringMatchTests.cs index cac692e7..94630c80 100644 --- a/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkStringMatchTests.cs +++ b/tests/SIL.Machine.Tests/PunctuationAnalysis/QuotationMarkStringMatchTests.cs @@ -188,13 +188,24 @@ public void GetPreviousCharacter() 0, 1 ); - ; + Assert.IsNull(quotationMarkStringMatch.PreviousCharacter); + quotationMarkStringMatch = new QuotationMarkStringMatch( new TextSegment.Builder().SetText("\u201c\u201d").Build(), 1, 2 ); Assert.That(quotationMarkStringMatch.PreviousCharacter, Is.EqualTo("“")); + + quotationMarkStringMatch = new QuotationMarkStringMatch( + new TextSegment.Builder() + .SetText("\"उत्पत्ति पुस्तकले") + .SetPreviousSegment(new TextSegment.Builder().SetText("उत्पत्ति पुस्तकले").Build()) + .Build(), + 0, + 1 + ); + Assert.That(quotationMarkStringMatch.PreviousCharacter, Is.EqualTo("ले")); } [Test]