View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0028686 | FPC | Misc | public | 2015-09-16 13:23 | 2016-06-12 07:32 |
Reporter | tintinux | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Platform | Any | OS | Windows | ||
Product Version | 2.6.4 | ||||
Summary | 0028686: FormatSettings.ThousandSeparator don't accept multbyte character | ||||
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 | ||||
Tags | No tags attached. | ||||
Fixed in Revision | |||||
FPCOldBugId | |||||
FPCTarget | |||||
Attached Files |
|
related to | 0027086 | new | FPC | FormatSettings do not support changing DefaultSystemCodePage | |
has duplicate | 0028762 | closed | Jonas Maebe | FPC | TFormatSettings char fields |
related to | 0030253 | resolved | Ondrej Pokorny | Lazarus | FormatFloat('#,'...); Become working incorrect after changing screen resolution |
|
First of all: support for 2.6 branch has stopped, so there will be no fixes for that. In essence this is a Lazarus problem. With 3.0 branch (3.0.1RC1 or trunk): Try - Supply an AnsiString(cp_1252) to the function, then convert to CP_UTF8? - Or use the "Set Utf-8 in RTL" option in Project Options and test again? |
|
Aside from: I always had problems fitting "ordinateur" in my two char field. I don't think this is either a good proposal or solvable in the way proposed. It has and still is being discussed on the forum. |
|
Bart, Ok, it can be fixed in 3.x Yes, this is a problem we encounter with Lazarus, but I think the best solution is in FPC. The first solution is not solving the issue efficiently. It requires a lot of changes in many Lazarus libraries and it cannot deal easily with complex format strings (please, see my example). Can you explain a little more how the "Set Utf-8 in RTL" option can solve the issue ? Is it new to 3.0 ? Thanks |
|
Seems in Delphi it is still (unicode)char http://docwiki.embarcadero.com/Libraries/XE3/en/System.SysUtils.TFormatSettings |
|
Ping: not only the characters can be wide (thus in UTF-8 more chars) but Windows also accepts up to 3 widecharacter separators. E.g. the Slovak date separator is '. ' (yes a dot followed by space). All the TFormatSettings.*Separator should be changed to string regardless what Delphi is. |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-09-16 13:23 | tintinux | New Issue | |
2015-09-16 13:38 | Bart Broersma | Note Added: 0085964 | |
2015-09-16 15:23 | Thaddy de Koning | Note Added: 0085970 | |
2015-09-16 15:24 | Thaddy de Koning | Note Edited: 0085970 | View Revisions |
2015-09-17 09:49 | tintinux | Note Added: 0085975 | |
2015-09-17 13:42 | Marco van de Voort | Note Added: 0085978 | |
2015-10-01 07:46 | Jonas Maebe | Relationship added | has duplicate 0028762 |
2015-10-01 07:46 | Jonas Maebe | Relationship added | related to 0027086 |
2016-06-12 07:27 | Ondrej Pokorny | Note Added: 0093140 | |
2016-06-12 07:27 | Ondrej Pokorny | Relationship added | related to 0030253 |