Try to implement UnicodeFromLocaleChars for java

This commit is contained in:
Pierre Muller 2024-03-05 20:58:30 +00:00
parent f7d6201946
commit 5a7d5367d2
2 changed files with 25 additions and 0 deletions

View File

@ -1047,6 +1047,8 @@ function StringToWideChar(const Src : RawByteString;Dest : PWideChar;DestSize :
end;
{$endif FPC_HAS_STRING_LEN_TO_WIDECHAR}
{$ifndef FPC_HAS_UNICODEFROMLOCALECHARS}
{$define FPC_HAS_UNICODEFROMLOCALECHARS}
function UnicodeFromLocaleChars(CodePage, Flags: Cardinal; LocaleStr: PAnsiChar;
LocaleStrLen: Integer; UnicodeStr: PWideChar; UnicodeStrLen: Integer): Integer; overload;
@ -1067,6 +1069,7 @@ begin
// Return length
result:=len;
end;
{$endif ndef FPC_HAS_UNICODEFROMLOCALECHARS}
function UnicodeFromLocaleChars(const LocaleName: AnsiString; Flags: Cardinal;
LocaleStr: PAnsiChar; LocaleStrLen: Integer; UnicodeStr: PWideChar;

View File

@ -624,6 +624,28 @@ function StringToWideChar(const Src : RawByteString;Dest : PWideChar;DestSize :
result:=Dest;
end;
{$define FPC_HAS_UNICODEFROMLOCALECHARS}
function UnicodeFromLocaleChars(CodePage, Flags: Cardinal; LocaleStr: PAnsiChar;
LocaleStrLen: Integer; UnicodeStr: PWideChar; UnicodeStrLen: Integer): Integer; overload;
var
temp: widestring;
Len: SizeInt;
begin
widestringmanager.Ansi2WideMoveProc(LocaleStr,CodePage,temp,LocaleStrLen);
Len:=Length(temp);
// Only move when we have room.
if (UnicodeStrLen>0) then
begin
if UnicodeStrLen<=Len then
Len:=UnicodeStrLen-1;
JLString(temp).getChars(0,Len,TJCharArray(UnicodeStr),0);
UniCodeStr[Len]:=#0;
end;
// Return length
result:=len;
end;
{$define FPC_HAS_UNICODECHAR_LEN_TO_STRING}
function UnicodeCharLenToString(S : PUnicodeChar;Len : SizeInt) : UnicodeString;