From 5066ff60d0962036c6376e628a1b22558e6e6831 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Thu, 14 Feb 2008 21:21:56 +0000 Subject: [PATCH] Fixes unicode string conversion routine on wince. CP_UTF8 isn't support on WinCE. git-svn-id: trunk@14137 - --- lcl/interfaces/wince/winceint.pp | 5 +---- lcl/interfaces/wince/winceproc.pp | 21 ++++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lcl/interfaces/wince/winceint.pp b/lcl/interfaces/wince/winceint.pp index a30ab7655a..f46a0da6ee 100644 --- a/lcl/interfaces/wince/winceint.pp +++ b/lcl/interfaces/wince/winceint.pp @@ -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 } diff --git a/lcl/interfaces/wince/winceproc.pp b/lcl/interfaces/wince/winceproc.pp index 079844eba0..d495ac2585 100644 --- a/lcl/interfaces/wince/winceproc.pp +++ b/lcl/interfaces/wince/winceproc.pp @@ -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}