mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-24 08:39:18 +02:00
* Fix bug #28258, missing UTF8ToString, patch by Stocki
git-svn-id: trunk@32824 -
This commit is contained in:
parent
ca2b1f97ed
commit
ee2f34588d
rtl/inc
@ -136,6 +136,12 @@ function Utf8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PChar
|
||||
function UTF8Encode(const s : RawByteString) : RawByteString; inline;
|
||||
function UTF8Encode(const s : UnicodeString) : RawByteString;
|
||||
function UTF8Decode(const s : RawByteString): UnicodeString;
|
||||
function UTF8ToString(const s : UTF8String): UnicodeString;inline;
|
||||
function UTF8ToString(const s : RawByteString): UnicodeString;inline;
|
||||
function UTF8ToString(const S: ShortString): unicodestring;
|
||||
function UTF8ToString(const S: PAnsiChar): unicodestring;
|
||||
function UTF8ToString(const S: array of AnsiChar): unicodestring;
|
||||
function UTF8ToString(const S: array of Byte): unicodestring;
|
||||
function AnsiToUtf8(const s : RawByteString): RawByteString;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
function Utf8ToAnsi(const s : RawByteString) : RawByteString;{$ifdef SYSTEMINLINE}inline;{$endif}
|
||||
function UnicodeStringToUCS4String(const s : UnicodeString) : UCS4String;
|
||||
|
@ -2355,3 +2355,64 @@ Begin
|
||||
Result:=Str;
|
||||
SetCodePage(Result,DefaultFileSystemCodePage,True);
|
||||
End;
|
||||
|
||||
function UTF8ToString(const S: UTF8String): UnicodeString; inline;
|
||||
begin
|
||||
Result := UTF8Decode(S);
|
||||
end;
|
||||
|
||||
function UTF8ToString(const S: RawByteString): UnicodeString; inline;
|
||||
|
||||
Var
|
||||
UTF8 : UTF8String;
|
||||
|
||||
begin
|
||||
UTF8:=S;
|
||||
Result := UTF8Decode(UTF8);
|
||||
end;
|
||||
|
||||
function UTF8ToString(const S: ShortString): UnicodeString;
|
||||
|
||||
Var
|
||||
UTF8 : UTF8String;
|
||||
|
||||
begin
|
||||
UTF8:=S;
|
||||
Result := UTF8Decode(UTF8);
|
||||
end;
|
||||
|
||||
function UTF8ToString(const S: PAnsiChar): UnicodeString;
|
||||
var
|
||||
UTF: UTF8String;
|
||||
Count: Integer;
|
||||
begin
|
||||
Count := StrLen(S);
|
||||
SetLength(UTF, Count);
|
||||
if Count > 0 then
|
||||
Move(S^, UTF[1], Count);
|
||||
Result := UTF8ToString(UTF);
|
||||
end;
|
||||
|
||||
function UTF8ToString(const S: array of AnsiChar): UnicodeString;
|
||||
var
|
||||
UTF: UTF8String;
|
||||
Count: Integer;
|
||||
begin
|
||||
Count := Length(S);
|
||||
SetLength(UTF, Count);
|
||||
if Count > 0 then
|
||||
Move(S[Low(S)], UTF[1], Count);
|
||||
Result := UTF8ToString(UTF);
|
||||
end;
|
||||
|
||||
function UTF8ToString(const S: array of Byte): UnicodeString;
|
||||
var
|
||||
UTF: UTF8String;
|
||||
Count: Integer;
|
||||
begin
|
||||
Count := Length(S);
|
||||
SetLength(UTF, Count);
|
||||
if Count > 0 then
|
||||
Move(S[Low(S)], UTF[1], Count);
|
||||
Result := UTF8ToString(UTF);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user