You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2022/05/19 09:25:41 UTC

[commons-text] branch master updated (c7361037 -> 4de4ee15)

This is an automated email from the ASF dual-hosted git repository.

kinow pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git


    from c7361037 Javadocs.
     new 7b6f8fed [TEXT-209] Fixed LookupTranslator returns count of codepoints consumed
     new 5cca5a51 [TEXT-209] Changelog
     new 4de4ee15 Merge branch 'pr-324'

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                                     |  1 +
 .../org/apache/commons/text/translate/LookupTranslator.java |  2 +-
 .../apache/commons/text/translate/LookupTranslatorTest.java | 13 +++++++++++++
 3 files changed, 15 insertions(+), 1 deletion(-)


[commons-text] 02/03: [TEXT-209] Changelog

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 5cca5a511a8ea319ae3ed8aa55d07b68d73a9a41
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Thu May 19 21:24:01 2022 +1200

    [TEXT-209] Changelog
---
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 19a9f295..eca43f0a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -67,6 +67,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action                  type="fix" dev="ggregory" due-to="CodeQL, Gary Gregory">TextStringBuilder.TextStringBuilderReader.skip(long): Throw an exception when an implicit narrowing conversion in a compound assignment would result in information loss or a numeric error such as an overflows.</action>
     <action issue="TEXT-211" type="fix" dev="ggregory" due-to="sebx59">TextStringBuilder.equals whatever the capacity is #281.</action>
     <action issue="TEXT=212" type="fix" dev="kinow" due-to="Ali Ghanbari">A More Efficient Implementation for Calculating Size of Longest Common Subsequence</action>
+    <action issue="TEXT-209" type="fix" dev="kinow" due-to="fourAjeff">LookupTranslator returns count of chars consumed, not of codepoints consumed</action>
     <!-- ADD -->
     <action issue="TEXT-207" type="add" dev="mattjuntunen">Add DoubleFormat utility.</action>
     <action issue="TEXT-190" type="add" dev="kinow" due-to="Benjamin Bing">Document negative limit for WordUtils abbreviate method</action>


[commons-text] 01/03: [TEXT-209] Fixed LookupTranslator returns count of codepoints consumed

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 7b6f8fedb57341e75e0abb250959840a89c38561
Author: linjianhui <12...@qq.com>
AuthorDate: Thu May 19 14:14:40 2022 +0800

    [TEXT-209] Fixed LookupTranslator returns count of codepoints consumed
---
 .../org/apache/commons/text/translate/LookupTranslator.java |  2 +-
 .../apache/commons/text/translate/LookupTranslatorTest.java | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/text/translate/LookupTranslator.java b/src/main/java/org/apache/commons/text/translate/LookupTranslator.java
index 18a7c93d..8c12a6da 100644
--- a/src/main/java/org/apache/commons/text/translate/LookupTranslator.java
+++ b/src/main/java/org/apache/commons/text/translate/LookupTranslator.java
@@ -95,7 +95,7 @@ public class LookupTranslator extends CharSequenceTranslator {
 
                 if (result != null) {
                     writer.write(result);
-                    return i;
+                    return Character.codePointCount(subSeq, 0, subSeq.length());
                 }
             }
         }
diff --git a/src/test/java/org/apache/commons/text/translate/LookupTranslatorTest.java b/src/test/java/org/apache/commons/text/translate/LookupTranslatorTest.java
index 8ca8e2f4..ad533f72 100644
--- a/src/test/java/org/apache/commons/text/translate/LookupTranslatorTest.java
+++ b/src/test/java/org/apache/commons/text/translate/LookupTranslatorTest.java
@@ -61,4 +61,17 @@ public class LookupTranslatorTest  {
         assertThatExceptionOfType(InvalidParameterException.class).isThrownBy(() -> new LookupTranslator(null));
     }
 
+    @Test
+    public void testTranslateSupplementaryCharacter() {
+        /* Key: string with Mathematical double-struck capital A (U+1D538) */
+        String symbol = new StringBuilder().appendCodePoint(0x1D538).toString();
+        /* Map U+1D538 to "A" */
+        Map<CharSequence, CharSequence> map = new HashMap<>();
+        map.put(symbol, "A");
+        LookupTranslator translator = new LookupTranslator(map);
+        String translated = translator.translate(symbol + "=A");
+        /* we should get "A=A". */
+        assertThat(translated).as("Incorrect value").isEqualTo("A=A");
+    }
+
 }


[commons-text] 03/03: Merge branch 'pr-324'

Posted by ki...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 4de4ee15d01b5f0cd3282ae670981d5cb5aa250a
Merge: c7361037 5cca5a51
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Thu May 19 21:25:05 2022 +1200

    Merge branch 'pr-324'
    
    This closes #324

 src/changes/changes.xml                                     |  1 +
 .../org/apache/commons/text/translate/LookupTranslator.java |  2 +-
 .../apache/commons/text/translate/LookupTranslatorTest.java | 13 +++++++++++++
 3 files changed, 15 insertions(+), 1 deletion(-)