Fixes unicode string conversion routine on wince. CP_UTF8 isn't support on WinCE.

git-svn-id: trunk@14137 -
This commit is contained in:
sekelsenmat 2008-02-14 21:21:56 +00:00
parent 56f8f68047
commit 5066ff60d0
2 changed files with 9 additions and 17 deletions

View File

@ -196,7 +196,7 @@ type
property OnAsyncSocketMsg: TSocketEvent read FOnAsyncSocketMsg write FOnAsyncSocketMsg;
end;
{$I wincelistslh.inc}
{$I wincelistslh.inc}
const
@ -210,9 +210,6 @@ const
ScrollBarClsName: array[0..9] of WideChar = ('S','C','R','O','L','L','B','A','R',#0);
ListBoxClsName: array[0..7] of WideChar = ('L','I','S','T','B','O','X',#0);
CP_UTF7 = 65000; { UTF-7 translation }
CP_UTF8 = 65001; { UTF-8 translation }
{ export for widgetset implementation }

View File

@ -115,11 +115,6 @@ uses
SysUtils, LCLStrConsts, Dialogs, StdCtrls, ExtCtrls,
LCLIntf; //remove this unit when GetWindowSize is moved to TWSWinControl
{ Constants missing from the Windows CE RTL. Remove when the RTL has them }
const
CP_UTF7 = 65000;
CP_UTF8 = 65001;
{ Converts a LCL string into a PWideChar.
With Unicode support activated the input string must be in
@ -131,18 +126,18 @@ const
function LCLStringToPWideChar(inString: string): PWideChar;
{$ifdef WindowsUnicodeSupport}
var
outStrLen: integer;
WideBuffer: widestring;
{$endif}
begin
{$ifdef WindowsUnicodeSupport}
{ First verifies how much space the new string will require }
outStrLen := MultiByteToWideChar(CP_UTF8, 0, PChar(inString), -1, nil, 0);
{ Converts to a buffer }
WideBuffer := Utf8Decode(inString);
{ Allocates memory for the string }
Result := GetMem(Length(WideBuffer) * 2 + 2);
{ Allocates space for the new string }
Result := GetMem(outStrLen*2);
{ Now effectively does the conversion }
MultiByteToWideChar(CP_UTF8, 0, PChar(inString), -1, Result, outStrLen);
{ Copies to the final destination }
Move(WideBuffer[1], Result^, Length(WideBuffer) * 2 + 2);
{$else}
Result := StringToPWideChar(inString);
{$endif}