mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 09:06:14 +02:00
* Moved WideString-related code, which is identical for Win32 and Win64, into syswin.inc
* Defined HAS_WIDESTRINGMANAGER for Win32 and Win64, this allows to smartlink away part of generic widestring routines. git-svn-id: trunk@17963 -
This commit is contained in:
parent
5a2d6c0429
commit
50952945e1
@ -273,6 +273,20 @@ function GetProcessID: SizeUInt;
|
|||||||
{******************************************************************************
|
{******************************************************************************
|
||||||
Unicode
|
Unicode
|
||||||
******************************************************************************}
|
******************************************************************************}
|
||||||
|
const
|
||||||
|
{ MultiByteToWideChar }
|
||||||
|
MB_PRECOMPOSED = 1;
|
||||||
|
CP_ACP = 0;
|
||||||
|
WC_NO_BEST_FIT_CHARS = $400;
|
||||||
|
|
||||||
|
function MultiByteToWideChar(CodePage:UINT; dwFlags:DWORD; lpMultiByteStr:PChar; cchMultiByte:longint; lpWideCharStr:PWideChar;cchWideChar:longint):longint;
|
||||||
|
stdcall; external 'kernel32' name 'MultiByteToWideChar';
|
||||||
|
function WideCharToMultiByte(CodePage:UINT; dwFlags:DWORD; lpWideCharStr:PWideChar; cchWideChar:longint; lpMultiByteStr:PChar;cchMultiByte:longint; lpDefaultChar:PChar; lpUsedDefaultChar:pointer):longint;
|
||||||
|
stdcall; external 'kernel32' name 'WideCharToMultiByte';
|
||||||
|
function CharUpperBuff(lpsz:LPWSTR; cchLength:DWORD):DWORD;
|
||||||
|
stdcall; external 'user32' name 'CharUpperBuffW';
|
||||||
|
function CharLowerBuff(lpsz:LPWSTR; cchLength:DWORD):DWORD;
|
||||||
|
stdcall; external 'user32' name 'CharLowerBuffW';
|
||||||
|
|
||||||
procedure Win32Unicode2AnsiMove(source:punicodechar;var dest:ansistring;len:SizeInt);
|
procedure Win32Unicode2AnsiMove(source:punicodechar;var dest:ansistring;len:SizeInt);
|
||||||
var
|
var
|
||||||
@ -316,6 +330,38 @@ function Win32UnicodeLower(const s : UnicodeString) : UnicodeString;
|
|||||||
CharLowerBuff(LPWSTR(result),length(result));
|
CharLowerBuff(LPWSTR(result),length(result));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{******************************************************************************
|
||||||
|
Widestring
|
||||||
|
******************************************************************************}
|
||||||
|
|
||||||
|
procedure Win32Ansi2WideMove(source:pchar;var dest:widestring;len:SizeInt);
|
||||||
|
var
|
||||||
|
destlen: SizeInt;
|
||||||
|
begin
|
||||||
|
// retrieve length including trailing #0
|
||||||
|
// not anymore, because this must also be usable for single characters
|
||||||
|
destlen:=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, source, len, nil, 0);
|
||||||
|
// this will null-terminate
|
||||||
|
setlength(dest, destlen);
|
||||||
|
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, source, len, @dest[1], destlen);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function Win32WideUpper(const s : WideString) : WideString;
|
||||||
|
begin
|
||||||
|
result:=s;
|
||||||
|
if length(result)>0 then
|
||||||
|
CharUpperBuff(LPWSTR(result),length(result));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function Win32WideLower(const s : WideString) : WideString;
|
||||||
|
begin
|
||||||
|
result:=s;
|
||||||
|
if length(result)>0 then
|
||||||
|
CharLowerBuff(LPWSTR(result),length(result));
|
||||||
|
end;
|
||||||
|
|
||||||
type
|
type
|
||||||
PWStrInitEntry = ^TWStrInitEntry;
|
PWStrInitEntry = ^TWStrInitEntry;
|
||||||
TWStrInitEntry = record
|
TWStrInitEntry = record
|
||||||
|
@ -27,6 +27,7 @@ interface
|
|||||||
{$endif cpui386}
|
{$endif cpui386}
|
||||||
|
|
||||||
{$define DISABLE_NO_THREAD_MANAGER}
|
{$define DISABLE_NO_THREAD_MANAGER}
|
||||||
|
{$define HAS_WIDESTRINGMANAGER}
|
||||||
|
|
||||||
{ include system-independent routine headers }
|
{ include system-independent routine headers }
|
||||||
{$I systemh.inc}
|
{$I systemh.inc}
|
||||||
@ -827,52 +828,6 @@ end;
|
|||||||
|
|
||||||
{$endif Set_i386_Exception_handler}
|
{$endif Set_i386_Exception_handler}
|
||||||
|
|
||||||
const
|
|
||||||
{ MultiByteToWideChar }
|
|
||||||
MB_PRECOMPOSED = 1;
|
|
||||||
CP_ACP = 0;
|
|
||||||
WC_NO_BEST_FIT_CHARS = $400;
|
|
||||||
|
|
||||||
function MultiByteToWideChar(CodePage:UINT; dwFlags:DWORD; lpMultiByteStr:PChar; cchMultiByte:longint; lpWideCharStr:PWideChar;cchWideChar:longint):longint;
|
|
||||||
stdcall; external 'kernel32' name 'MultiByteToWideChar';
|
|
||||||
function WideCharToMultiByte(CodePage:UINT; dwFlags:DWORD; lpWideCharStr:PWideChar; cchWideChar:longint; lpMultiByteStr:PChar;cchMultiByte:longint; lpDefaultChar:PChar; lpUsedDefaultChar:pointer):longint;
|
|
||||||
stdcall; external 'kernel32' name 'WideCharToMultiByte';
|
|
||||||
function CharUpperBuff(lpsz:LPWSTR; cchLength:DWORD):DWORD;
|
|
||||||
stdcall; external 'user32' name 'CharUpperBuffW';
|
|
||||||
function CharLowerBuff(lpsz:LPWSTR; cchLength:DWORD):DWORD;
|
|
||||||
stdcall; external 'user32' name 'CharLowerBuffW';
|
|
||||||
|
|
||||||
{******************************************************************************
|
|
||||||
Widestring
|
|
||||||
******************************************************************************}
|
|
||||||
|
|
||||||
procedure Win32Ansi2WideMove(source:pchar;var dest:widestring;len:SizeInt);
|
|
||||||
var
|
|
||||||
destlen: SizeInt;
|
|
||||||
begin
|
|
||||||
// retrieve length including trailing #0
|
|
||||||
// not anymore, because this must also be usable for single characters
|
|
||||||
destlen:=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, source, len, nil, 0);
|
|
||||||
// this will null-terminate
|
|
||||||
setlength(dest, destlen);
|
|
||||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, source, len, @dest[1], destlen);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function Win32WideUpper(const s : WideString) : WideString;
|
|
||||||
begin
|
|
||||||
result:=s;
|
|
||||||
if length(result)>0 then
|
|
||||||
CharUpperBuff(LPWSTR(result),length(result));
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function Win32WideLower(const s : WideString) : WideString;
|
|
||||||
begin
|
|
||||||
result:=s;
|
|
||||||
if length(result)>0 then
|
|
||||||
CharLowerBuff(LPWSTR(result),length(result));
|
|
||||||
end;
|
|
||||||
|
|
||||||
{******************************************************************************}
|
{******************************************************************************}
|
||||||
{ include code common with win64 }
|
{ include code common with win64 }
|
||||||
|
@ -24,6 +24,7 @@ interface
|
|||||||
{$endif SYSTEMDEBUG}
|
{$endif SYSTEMDEBUG}
|
||||||
|
|
||||||
{$define DISABLE_NO_THREAD_MANAGER}
|
{$define DISABLE_NO_THREAD_MANAGER}
|
||||||
|
{$define HAS_WIDESTRINGMANAGER}
|
||||||
|
|
||||||
{ include system-independent routine headers }
|
{ include system-independent routine headers }
|
||||||
{$I systemh.inc}
|
{$I systemh.inc}
|
||||||
@ -883,55 +884,6 @@ procedure fpc_cpucodeinit;
|
|||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{****************************************************************************
|
|
||||||
OS dependend widestrings
|
|
||||||
****************************************************************************}
|
|
||||||
|
|
||||||
const
|
|
||||||
{ MultiByteToWideChar }
|
|
||||||
MB_PRECOMPOSED = 1;
|
|
||||||
CP_ACP = 0;
|
|
||||||
WC_NO_BEST_FIT_CHARS = $400;
|
|
||||||
|
|
||||||
function MultiByteToWideChar(CodePage:UINT; dwFlags:DWORD; lpMultiByteStr:PChar; cchMultiByte:longint; lpWideCharStr:PWideChar;cchWideChar:longint):longint;
|
|
||||||
stdcall; external 'kernel32' name 'MultiByteToWideChar';
|
|
||||||
function WideCharToMultiByte(CodePage:UINT; dwFlags:DWORD; lpWideCharStr:PWideChar; cchWideChar:longint; lpMultiByteStr:PChar;cchMultiByte:longint; lpDefaultChar:PChar; lpUsedDefaultChar:pointer):longint;
|
|
||||||
stdcall; external 'kernel32' name 'WideCharToMultiByte';
|
|
||||||
function CharUpperBuff(lpsz:LPWSTR; cchLength:DWORD):DWORD;
|
|
||||||
stdcall; external 'user32' name 'CharUpperBuffW';
|
|
||||||
function CharLowerBuff(lpsz:LPWSTR; cchLength:DWORD):DWORD;
|
|
||||||
stdcall; external 'user32' name 'CharLowerBuffW';
|
|
||||||
|
|
||||||
|
|
||||||
procedure Win32Ansi2WideMove(source:pchar;var dest:widestring;len:SizeInt);
|
|
||||||
var
|
|
||||||
destlen: SizeInt;
|
|
||||||
begin
|
|
||||||
// retrieve length including trailing #0
|
|
||||||
// not anymore, because this must also be usable for single characters
|
|
||||||
destlen:=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, source, len, nil, 0);
|
|
||||||
// this will null-terminate
|
|
||||||
setlength(dest, destlen);
|
|
||||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, source, len, @dest[1], destlen);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function Win32WideUpper(const s : WideString) : WideString;
|
|
||||||
begin
|
|
||||||
result:=s;
|
|
||||||
UniqueString(result);
|
|
||||||
if length(result)>0 then
|
|
||||||
CharUpperBuff(LPWSTR(result),length(result));
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function Win32WideLower(const s : WideString) : WideString;
|
|
||||||
begin
|
|
||||||
result:=s;
|
|
||||||
UniqueString(result);
|
|
||||||
if length(result)>0 then
|
|
||||||
CharLowerBuff(LPWSTR(result),length(result));
|
|
||||||
end;
|
|
||||||
|
|
||||||
{******************************************************************************}
|
{******************************************************************************}
|
||||||
{ include code common with win64 }
|
{ include code common with win64 }
|
||||||
|
Loading…
Reference in New Issue
Block a user