You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2021/03/04 12:41:11 UTC

[GitHub] [daffodil] stevedlawrence commented on a change in pull request #495: Patterns to match strings with newlines.

stevedlawrence commented on a change in pull request #495:
URL: https://github.com/apache/daffodil/pull/495#discussion_r587433059



##########
File path: daffodil-lib/src/main/scala/org/apache/daffodil/xml/XMLUtils.scala
##########
@@ -702,6 +706,17 @@ object XMLUtils {
     res
   }
 
+  def isXMLIllegalChar(i: Int) = {
+    // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+    i match {
+      case 0x9 | 0xA | 0xD => false
+      case z if (z >= 0x20 && z <= 0xD7FF) => false
+      case z if (z >= 0xE000 && z <= 0xFFFD ) => false
+      case z if (z >= 0x10000 && z <= 0x10FFFF) => false
+      case _ => true
+    }
+  }
+

Review comment:
       Doesn't look like this is used anywhere? Is this jus a helpful tool that we may need in the future, or was the intentino to may replace some of the above code with it?
   
   Might also be worth modifying the comment to say "legal characters: ..." or something. Since the function is called isXMLIllegalChars I assumed that comment was the list of illegal charactes and was a bit confused.
   
   Also, just an FYI, I was curious to see how this match/catch compiled to bytecode compared to if-statements, and they end up exactly the same. Not too surprised, but good to know.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org