Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
Quality Central
Delphi-BCB
ActiveX
AddOn
Bold
CodeGuard
Compatibility
Compiler
CORBA
Database
Debugger
Demos
Documentation
Enterprise
IDE
Install
International
Internet
Linker
MFC Support
Midas
Modeling
MTS
Resourcing
RTL
C++
Delphi
SOAP
TASM/TD
Tools CL
VCL
VCLX
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/RTL
[ Add a report in this area ]
Report #:
78134
Status:
Open
WideCharToMultibyte() of Windows 2000 miscalculates the size of the buffer
Project:
Delphi
Build #:
12.0.3420.21218
Version:
12.3
Submitted By:
Hideaki Tominaga
Report Type:
Crash / Data loss / Total failure
Date Reported:
9/27/2009 10:41:30 AM
Severity:
Serious / Highly visible problem
Last Updated:
9/29/2009 12:00:11 AM
Platform:
95, 98, 2000, NT, XP
Internal Tracking #:
273063
Resolution:
None
(Resolution Comments)
Resolved in Build:
:
None
Duplicate of:
None
Voting and Rating
Overall Rating:
No Ratings Yet
0.00 out of 5
Total Votes:
18
Description
WideCharToMultibyte() of Windows 2000 miscalculates the size of the buffer.
The routine for which WideCharToMultibyte() is used might not work correctly with Windows 2000.
- TypInfo.SetRawByteStrProp()
- WideStrutils.Utf8ToAnsiEx()
- System.CharFromWChar()
- SysUtils.TMBCSEncoding.GetByteCount()
- SysUtils.TMBCSEncoding.GetBytes()
Of course, TEncoding is influenced, too.
Indy also has the same problem.
- IdGlobal.TIdMBCSEncoding.GetByteCount()
- IdGlobal.TIdMBCSEncoding.GetBytes()
See Also:
[ ISO/IEC 2022 ]
http://en.wikipedia.org/wiki/ISO/IEC_2022
Steps to Reproduce:
[Test Case 1]
--------------------------------------------------------------------------------
1.Execute Project1.exe (Attachments).
2.Press [Save] button.
3.Press [Load] button.
EXP:
Windows 2000 / XP / Vista / 7:
Works fine.
ACT:
Windows XP / Vista / 7:
Works fine.
Windows 2000:
String is truncated.
[Test Case 2]
--------------------------------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
type
ISO2022_1 = type AnsiString(50220); // 50221 50222 50225 50227 50229 is also the same
var
FmtStr,
W1,W2: UnicodeString;
ISO1: ISO2022_1;
begin
FmtStr := 'CP%d:'#$0D#$0A'W1=%s(%d)'#$0D#$0A'W2=%s(%d)';
// ISO-2022-JP / ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS)
W1 := '123'#$3053#$3093#$306B#$3061#$306F'456';
ISO1 := W1;
W2 := ISO1;
ShowMessage(Format(FmtStr, [50220, W1, Length(W1), W2, Length(W2)]));
end;
EXP:
Windows 2000 / XP / Vista / 7:
W1 and W2 are the same.
ACT:
Windows XP / Vista / 7:
W1 and W2 are the same.
Windows 2000:
String is truncated.
Please see MECSUtils ( http://cc.codegear.com/item/26061 )
UTF16ToAnsi() function
Workarounds
None
Attachment
QC78134.zip
Comments
Tomohiro Takahashi at 9/27/2009 8:55:12 PM
-
Is this issue a implementation problem of the API on Windows 2000?
If so, may I change Type field from A to E(or F) as Sysop?
Dick Boogaers at 9/28/2009 2:28:50 AM
-
If WideCharToMultibyte goes wrong in Windows2000, then all the functions mr. Tominaga lists in the report description go wrong. So, it's a serious bug indeed, suggesting that WideCharToMultibyte should be rewritten in system.pas.
Hideaki Tominaga at 9/27/2009 10:26:07 PM
-
>Is this issue a implementation problem of the API on Windows 2000?
Yes.
>If so, may I change Type field from A to E(or F) as Sysop?
No. Because it is not correct as the specification of the function and the method.
View Your Reports
Search
Server Response from: CODE1
Developer Tools
Blackfish SQL
C++Builder
Delphi
Delphi for PHP
Delphi Prism
InterBase
JBuilder
J Optimizer
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Chats
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us