View Issue Details

IDProjectCategoryView StatusLast Update
0024011FPCRTLpublic2013-03-14 14:48
ReporterBernard Marcelly Assigned ToMarco van de Voort  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
PlatformX86OSWindows XP 
Product Version2.6.0 
Summary0024011: Thousand separator does not follow regional preferences
DescriptionReproduced on Windows XP and Windows 8, on two computers with fr-FR regional preferences :
Thousand separator used is : space
Decimal separator used is : comma

ShowMessage( Format('%10.0n', [1234567.0]) )
displays: 1?234?567
Delphi 7 on the same computer correctly gives : 1 234 567

ShowMessage( IntToStr(ord(ThousandSeparator)) )
displays : 160 instead of 32
Steps To ReproduceShowMessage( Format('%10.0n', [1234567.0]) )

ShowMessage( IntToStr(ord(ThousandSeparator)) )
Additional InformationFYI : Decimal separator is correctly handled by Format() and by DecimalSeparator.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

José Mejuto

2013-03-07 16:24

reporter   ~0066093

Hello,

Your ThousandSeparator is not an space, but maybe a "non-breakable-space" which is outside of ASCII charset, so you are using an ANSI string as an UTF8 one. Try this:

ShowMessage(AnsiToUTF8(Format('%10.0n', [1234567.0])));

Space should not be used as thousand separator or some values will be splitted across line changes. The same happends with euro symbol in currency formats.

Vojtech Cihak

2013-03-07 18:14

reporter   ~0066097

Last edited: 2013-03-07 18:32

View 2 revisions

I can reproduce: Lazarus 1.1 r40358M FPC 2.7.1 r23627 x86_64-linux-qt openSuSE 12.2, KDE4.8.5
In a project with unit "clocale" added to "uses" of *.lpr file.

In system settings, I have no separator for numbers and "." for money.
I don't know where "clocale" digs the info.

EDIT: BTW, this FPC issue.

Marco van de Voort

2013-03-07 20:11

manager   ~0066101

Last edited: 2013-03-07 20:12

View 3 revisions

FPC functions do not return utf8 by default (yet). So this is per spec.

clocale links to libc for the data.

Marco van de Voort

2013-03-12 22:09

manager   ~0066202

Close then? 160 seems to be expected answer atm for a nonbreaking space?

Marco van de Voort

2013-03-13 12:49

manager   ~0066211

Not clear what should be fixed FPC side. Last call before closing.

Bernard Marcelly

2013-03-13 13:39

reporter   ~0066212

Last edited: 2013-03-13 13:42

View 2 revisions

Sorry for the delay...

160 is the code for non-breaking space in ANSI as well as Unicode, see http://ascii-table.com/ansi-codes.php

But then the problem is the display of the character 0000160.
It should display as a space, not as a '?'.

Furthermore I found an inconsistency in displays:
(character pound shows bad in the report, read pound160)
ShowMessage('AB' +0000160 +'C') displays AB
ShowMessage('AB' +0000160 +'CD') displays AB
ShowMessage('AB' +0000160 +'CDE') displays AB?CDE

Bart Broersma

2013-03-13 15:23

reporter   ~0066217

ShowMessage is Lazarus and requires UTF8.

Marco van de Voort

2013-03-13 17:32

manager   ~0066219

Last edited: 2013-03-13 21:50

View 3 revisions

Yes, which is why I moved it to Lazarus. But you tossed it back.


FPC still delivers ansi (or default 1-byte encoding, in the case of *nix) in every function. If you want to output UTF8, you need convert it. Which was my point for closing with "not a bug" status.

Bart Broersma

2013-03-13 23:32

reporter   ~0066223

> Yes, which is why I moved it to Lazarus. But you tossed it back.
Because it is not a bug on Lazarus as well. LCL=UTF8. Programmer needs to deal with that.

B.t.w. I replied to Bernard, trying to point out it is not a bug, it's a feature. So actually I tried to tell him you were right: resolve as "no change required".

Vojtech Cihak

2013-03-14 01:17

reporter   ~0066224

So what is the solution?
Also:
writeln((Format('%10.0n', [1234567.0])));
writeln(AnsiToUTF8(Format('%10.0n', [1234567.0])));
outputs:
1�234�567
1?234?567

Lazarus 1.1 r40358M FPC 2.7.1 r23627

Marco van de Voort

2013-03-14 10:21

manager   ~0066226

Resolved as discussed.

Vojtech: be careful that your way to debug (writeln) doesn't introduce other codepage issues. Recommend to continue discussion/question on maillist or forum.

Bernard Marcelly

2013-03-14 14:48

reporter   ~0066228

I agree, no change required. But the problem is not simple, see my last note at http://lazarus.freepascal.org/index.php/topic,20163.0.html

Issue History

Date Modified Username Field Change
2013-03-07 15:09 Bernard Marcelly New Issue
2013-03-07 16:24 José Mejuto Note Added: 0066093
2013-03-07 17:01 Marco van de Voort Project FPC => Lazarus
2013-03-07 18:14 Vojtech Cihak Note Added: 0066097
2013-03-07 18:32 Vojtech Cihak Note Edited: 0066097 View Revisions
2013-03-07 20:11 Marco van de Voort Note Added: 0066101
2013-03-07 20:12 Marco van de Voort Note Edited: 0066101 View Revisions
2013-03-07 20:12 Marco van de Voort Note Edited: 0066101 View Revisions
2013-03-12 16:26 Bart Broersma Project Lazarus => FPC
2013-03-12 22:09 Marco van de Voort Note Added: 0066202
2013-03-13 12:49 Marco van de Voort Note Added: 0066211
2013-03-13 12:49 Marco van de Voort Assigned To => Marco van de Voort
2013-03-13 12:49 Marco van de Voort Status new => feedback
2013-03-13 13:39 Bernard Marcelly Note Added: 0066212
2013-03-13 13:39 Bernard Marcelly Status feedback => assigned
2013-03-13 13:42 Bernard Marcelly Note Edited: 0066212 View Revisions
2013-03-13 15:23 Bart Broersma Note Added: 0066217
2013-03-13 17:32 Marco van de Voort Note Added: 0066219
2013-03-13 21:50 Marco van de Voort Note Edited: 0066219 View Revisions
2013-03-13 21:50 Marco van de Voort Note Edited: 0066219 View Revisions
2013-03-13 23:32 Bart Broersma Note Added: 0066223
2013-03-14 01:17 Vojtech Cihak Note Added: 0066224
2013-03-14 10:21 Marco van de Voort Note Added: 0066226
2013-03-14 10:21 Marco van de Voort Status assigned => resolved
2013-03-14 10:21 Marco van de Voort Resolution open => no change required
2013-03-14 14:48 Bernard Marcelly Note Added: 0066228
2013-03-14 14:48 Bernard Marcelly Status resolved => closed