Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/RTL/Delphi/Format + Float    [ Add a report in this area ]  
Report #:  96192   Status: Closed
The width of the "format" function
Project:  Delphi Build #:  15.0.3953.3517
Version:    15.1 Submitted By:   shusaku suda
Report Type:  Basic functionality failure Date Reported:  7/13/2011 10:35:24 PM
Severity:    Serious / Highly visible problem Last Updated: 7/17/2011 4:39:57 AM
Platform:    All versions Internal Tracking #:  
Resolution: Test Case Error (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 1
Description
see attachments

code:
  Memo1.Lines.Add(Format('%10s', ['??']));
  Memo1.Lines.Add(Format('%10s', ['Japan']));

Result:
        ??
     Japan

Answer:
      ??
     Japan

Added by Sysop
<<<<<<<<<
? is a Japanese Kanji Character(multi-byte character).
>>>>>>>>>
Steps to Reproduce:
See Description.
Workarounds
None
Attachment
pic.zip
Comments

Tomohiro Takahashi at 7/14/2011 5:06:02 AM -
>  Memo1.Lines.Add(Format('%10s', ['??']));
> ...
> Result:
>       ??
> ...
> Answer:
>      ??
QualityCentral can not handle multi-byte character(e.g., Japanese Kanji Character).
So, could you tell us more detail about your issue and attach sample project to understand/confirm the issue?

shusaku suda at 7/14/2011 5:37:41 PM -
Thank you. Attached.

Tomohiro Takahashi at 7/15/2011 12:54:23 AM -
> The width of the "format" function
Could you write more detailed [Description] to understand/verify your issue?

shusaku suda at 7/15/2011 1:59:36 AM -
"Format ('% 10s', [Str])" with expected results, also want to arrange a string of multi-byte single-byte character string.

see 96192.png

Tomohiro Takahashi at 7/17/2011 4:27:44 AM -
Is this a regression?
How about previous versions of Delphi(e.g., Delphi 6, 7, 2007, 2009 etc...)?

shusaku suda at 7/18/2011 5:06:49 PM -
I, "Delphi XE Professional update1" has only.

Tomohiro Takahashi at 7/17/2011 4:59:34 PM -
As you know, recent versions of Delphi, string is UnicodeString, and Char is WideChar(16bit).
So, the lines below show 10 respectively as expected.
---------
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(IntToStr(Length(Format('%10s', ['XX']))));
  ShowMessage(IntToStr(Length(Format('%10s', ['Japan']))));
end;
---------
Note: X is a Japanese Kanji Character(multi-byte charactar).

If you migrate Ansi-based project with Unicode-based Delphi 2009,2010,XE, please use AnsiStrings unit and call its Ansi-based Format function instead as below.
---------
uses AnsiStrings;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Lines.Add(AnsiStrings.Format('%10s', ['XX']));
  Memo1.Lines.Add(AnsiStrings.Format('%10s', ['Japan']));
end;
---------
Note: X is a Japanese Kanji Character(multi-byte charactar).

shusaku suda at 7/18/2011 5:10:38 PM -
Thank you. Resolved.

Server Response from: ETNACODE01