mbeckerle commented on code in PR #1106:
URL: https://github.com/apache/daffodil/pull/1106#discussion_r1376445905


##########
daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/FixedICUDecimalFormat.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.daffodil.lib.util;
+
+import com.ibm.icu.text.DecimalFormat;
+import com.ibm.icu.text.DecimalFormatSymbols;
+
+import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class FixedICUDecimalFormat {
+
+    /**
+     * This regex enables us to correct a problem in ICUs interpretation of 
the pattern in the case
+     * where the pattern has no digits before the decimal points, such as 
"#.##"
+     * so that there should be zero leading digits if the integer part is 0.
+     * <p>
+     *     See https://unicode-org.atlassian.net/browse/ICU-22558
+     * <p>

Review Comment:
   Yeah, basically that code explicitly says "for backward compatibility" it 
always requires a 0 digit. That's in essence acknowledging that different 
behavior would also be useful, but then they're not offering any way to access 
that behavior. 
   
   This issue could be fixed in ICU by putting in a switch by which ICU API 
users have to explicitly enable it. 
   
   Then in Daffodil we could enable or disable this using a "dfdlx" property 
e.g., `dfdlx:textNumberPatternOptions="allowLeadingDecimalPoint"` or some such. 
   
   
   
   I think this feature is going to require us to diverge from ICU somehow, or 
to offer a switch to turn on correct behavior. 
   I can understand that for value 0, pattern "#.#" doesn't want to output just 
"."



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to