View Issue Details

IDProjectCategoryView StatusLast Update
0028686FPCMiscpublic2016-06-12 07:32
Reportertintinux Assigned To 
Status newResolutionopen 
Product Version2.6.4 
Summary0028686: FormatSettings.ThousandSeparator don't accept multbyte character
DescriptionThis 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

TagsNo tags attached.
Fixed in Revision
Attached Files


related to 0027086 new FPC FormatSettings do not support changing DefaultSystemCodePage 
has duplicate 0028762 closedJonas Maebe FPC TFormatSettings char fields 
related to 0030253 resolvedOndrej Pokorny Lazarus FormatFloat('#,'...); Become working incorrect after changing screen resolution 


Bart Broersma

2015-09-16 13:38

reporter   ~0085964

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):
- 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?

Thaddy de Koning

2015-09-16 15:23

reporter   ~0085970

Last edited: 2015-09-16 15:24

View 2 revisions

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.


2015-09-17 09:49

reporter   ~0085975


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 ?


Marco van de Voort

2015-09-17 13:42

manager   ~0085978

Seems in Delphi it is still (unicode)char

Ondrej Pokorny

2016-06-12 07:27

developer   ~0093140

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.

Issue History

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