|
@@ -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
|