FormatSettings.ThousandSeparator don't accept multbyte character
Original Reporter info from Mantis: tintinux
-
Reporter name:
Original Reporter info from Mantis: tintinux
- Reporter name:
Description:
This is a reopening of bug 0024011 with a proposed solution.
In Windows 7 and higher, in French and probably other localizations, the default value for ThousandSeparator is a non-breaking space, coded chr(160) in ISO 8859 charset. In UT8 charset, the non-breaking space is coded on 2 bytes (160,194).
To have a correct display in Lazarus gui application, we must display UTF8.
It is possible to encode the resultant string after formatting, but this is not suitable in any situation, when mixing text and numbers, and many libraries would need updates.
The best thing would be, IMHO, to set the separator to an UTF8 encoded charcater before formatting, and to call the Format function with this UTF8 encoded separator.
I don't expect the encoding of the separator to be done by FPC, I know FPC is independent of encodings. This can be done by the application during initialization.
The problem is that in UTF8 the non-breaking space is double-byte and it looks like that Format do not accept multibyte characters dor Separators.
Is it possible to change this in a future FPC release ?
Steps to reproduce:
// To display a length : "100 000 mètres" in an UTF-8 GUI.
FormatSettings.ThousandSeparator := chr(160); // the default for windows in France
showmessage ( Format( '%10.2n mètres', 100000 ); // wrong, normal should be displayed in UTF8
showmessage ( SysToUtf8 (Format( '%10.2n mètres', 10000000 )) // right for numeric part, but wrong for the unit name
var str : string ;
str := sysToUTF8(chr(160));
FormatSettings.ThousandSeparator := str[1];
showmessage ( Format( '%10.2n mètres', 10000000 ); // currently wrong, but should work
Mantis conversion info:
- Mantis ID: 28686
- OS: Windows
- OS Build: 7
- Platform: Any
- Version: 2.6.4
- Monitored by: » @onpok (Ondrej Pokorny), » Vincent (Vincent Snijders)