JDK-8037111 : space before % is inconsistent between sv and sv_SE
  • Type: Bug
  • Component: globalization
  • Sub-Component: locale-data
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2014-03-09
  • Updated: 2016-12-08
  • Resolved: 2016-12-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b148Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b124)
Java HotSpot(TM) Server VM (build 25.0-b66, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux ado-HP-625 3.8.0-35-generic #50-Ubuntu SMP Tue Dec 3 01:25:33 UTC 2013 i686 athlon i686 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
There's an unexpected space before the percentage sign if the locale is sv_SE. There's no space if the country is left out, though. The test case described below pretty much says it all.

REGRESSION.  Last worked in version 8

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See test case described below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"78,93%"
"78,93%"
"78,93%"
ACTUAL -
"78,93 %"
"78,93%"
"78,93%"

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public static String getPercentage(Locale locale, int decimals, double value) {
  //locale = new Locale(locale.getLanguage());
  NumberFormat formatter = NumberFormat.getPercentInstance(locale);
  formatter.setMinimumFractionDigits(decimals);
  formatter.setMaximumFractionDigits(decimals);
  return formatter.format(value);
}

assertEquals("78,93%", FormatterUtil.getPercentage(new Locale("sv", "SE"), 2, 0.7893));
assertEquals("78,93%", FormatterUtil.getPercentage(new Locale("sv"), 2, 0.7893));
assertEquals("78,93%", FormatterUtil.getPercentage(new Locale("sv", "FI"), 2, 0.7893));
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Uncomment the first line of getPercentage and the test case above will pass.


Comments
JDK9 java -Djava.locale.providers=CLDR,JRE 78,93��% 78,93��% 78,93��% java -Djava.locale.providers=JRE 78,93 % 78,93% 78,93% java -Djava.locale.providers=JRE,CLDR 78,93 % 78,93% 78,93��% JDK 8 78,93 % 78,93% 78,93%
08-09-2016

I will port the percent pattern to sv, but other patterns (decimal and currency) in sv will be the same as in Root (same as before).
12-03-2014

Sorry, I think it futher. It's in sv.xml in CLDR that there is an extra space before the percent sign. I should add the extra space in FormatData_sv.java rather than FormatData_sv_SE.java.
12-03-2014

Yes, the change is because of the bug fix JDK-8027695. In CLDR, sv.xml, it's - <percentFormat type="standard"> <pattern type="standard">#,##0 %</pattern> </percentFormat> There is a space before the percent sign. In http://en.wikipedia.org/wiki/Percent_sign, it says "According to the Swedish Language Council, the percent sign should be preceded by a space in Swedish." If there is no compatibility issue, I would like to close this bug. thanks, Yong
12-03-2014

The space was intentionally added with JDK-8027695 fix. Transferring to G11n for further investigation.
11-03-2014

Looks like an erroneous space character in src/share/classes/sun/text/resources/sv/FormatData_sv_SE.java
09-03-2014