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

andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git


The following commit(s) were added to refs/heads/main by this push:
     new b5ffb47  JENA-2100: Unicode unescape
     new 0ccbc46  Merge pull request #996 from afs/unicode-esc
b5ffb47 is described below

commit b5ffb47c76b83d1e0ac5081464cf272a4c252d7d
Author: Andy Seaborne <[email protected]>
AuthorDate: Sat May 1 12:26:26 2021 +0100

    JENA-2100: Unicode unescape
---
 .../java/org/apache/jena/atlas/lib/EscapeStr.java  |  1 -
 .../org/apache/jena/atlas/lib/TestEscapeStr.java   | 27 +++++++++++++++++-----
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/EscapeStr.java 
b/jena-base/src/main/java/org/apache/jena/atlas/lib/EscapeStr.java
index 82b7897..7d780e5 100644
--- a/jena-base/src/main/java/org/apache/jena/atlas/lib/EscapeStr.java
+++ b/jena-base/src/main/java/org/apache/jena/atlas/lib/EscapeStr.java
@@ -215,7 +215,6 @@ public class EscapeStr
             {
                 sb.append('\\') ;
                 sb.append(ch2) ;
-                i = i + 1 ;
                 continue ;
             }
 
diff --git 
a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestEscapeStr.java 
b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestEscapeStr.java
index 74e407a..84d8e83 100644
--- a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestEscapeStr.java
+++ b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestEscapeStr.java
@@ -21,18 +21,17 @@ package org.apache.jena.atlas.lib;
 import org.junit.Assert ;
 import org.junit.Test ;
 
-// Testing is a bit light here but the RDF term output and 
+// Testing is a bit light here but the RDF term output and
 // the language level output covers the ground as well.
-// See TestQuotedString in ARQ.
 
 public class TestEscapeStr {
-    
+
     @Test public void escape_str_01()   { test_esc("", "") ; }
     @Test public void escape_str_02()   { test_esc("A", "A") ; }
     @Test public void escape_str_03()   { test_esc("\n", "\\n") ; }
     @Test public void escape_str_04()   { test_esc("A\tB", "A\\tB") ; }
     @Test public void escape_str_05()   { test_esc("\"", "\\\"") ; }
-    
+
     @Test public void unescape_str_10()   { test_unesc("\\u0041", "A") ; }
     @Test public void unescape_str_11()   { test_unesc("\\U00000041", "A") ; }
     @Test public void unescape_str_12()   { test_unesc("12\\u004134", "12A34") 
; }
@@ -42,10 +41,26 @@ public class TestEscapeStr {
         String output = EscapeStr.stringEsc(input) ;
         Assert.assertEquals(expected, output);
     }
-    
+
     private void test_unesc(String input, String expected) {
         String output = EscapeStr.unescapeStr(input) ;
         Assert.assertEquals(expected, output);
     }
-    
+
+    @Test public void unescape_unicode_1()   { test_unesc_unicode("", "") ; }
+    @Test public void unescape_unicode_2()   { 
test_unesc_unicode("abc\\u0020def", "abc def") ; }
+    @Test public void unescape_unicode_3()   { test_unesc_unicode("\\u0020", " 
") ; }
+    @Test public void unescape_unicode_4()   { 
test_unesc_unicode("abc\\U00000020def", "abc def") ; }
+    @Test public void unescape_unicode_5()   { 
test_unesc_unicode("\\U00000020", " ") ; }
+
+    // Leaves non-unicode untouched.
+    @Test public void unescape_unicode_10()   { test_unesc_unicode("\\1\\2", 
"\\1\\2") ; }
+    @Test public void unescape_unicode_11()   { test_unesc_unicode("\\n\\t", 
"\\n\\t") ; }
+    @Test public void unescape_unicode_12()   { test_unesc_unicode("\\(\\)", 
"\\(\\)") ; }
+    @Test public void unescape_unicode_13()   { test_unesc_unicode("\\\\", 
"\\\\") ; }
+
+    private void test_unesc_unicode(String input, String expected) {
+        String output = EscapeStr.unescapeUnicode(input) ;
+        Assert.assertEquals(expected, output);
+    }
 }

Reply via email to