mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 07:30:22 +02:00
lazutils: paswstring: Unicode2AnsiMove, Ansi2UnicodeMove less strings
git-svn-id: trunk@47093 -
This commit is contained in:
parent
faa90467e8
commit
140ad30431
@ -20,6 +20,10 @@ unit PasWString;
|
|||||||
//{.$define PASWSTRING_SUPPORT_NONUTF8_ANSISTRING} disabled by default because
|
//{.$define PASWSTRING_SUPPORT_NONUTF8_ANSISTRING} disabled by default because
|
||||||
// non utf-8 ansistring is rare in UNIXes and lconvencoding makes the executable big
|
// non utf-8 ansistring is rare in UNIXes and lconvencoding makes the executable big
|
||||||
|
|
||||||
|
{$IF defined(EnableUTF8RTL) and defined(PASWSTRING_SUPPORT_NONUTF8_ANSISTRING)}
|
||||||
|
{$error UTF8 or not UTF8}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -314,16 +318,9 @@ end;
|
|||||||
{ Unicode }
|
{ Unicode }
|
||||||
|
|
||||||
procedure Unicode2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt);
|
procedure Unicode2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt);
|
||||||
var
|
|
||||||
widestr: unicodestring;
|
|
||||||
begin
|
begin
|
||||||
{$ifdef PASWSTRING_VERBOSE}WriteLn('Unicode2AnsiMove START');{$endif}
|
{$ifdef PASWSTRING_VERBOSE}WriteLn('Unicode2AnsiMove START');{$endif}
|
||||||
// Copy the originating string taking into account the specified length
|
dest := UTF16ToUTF8(source,len);
|
||||||
SetLength(widestr, len);
|
|
||||||
System.Move(source^, widestr[1], len*2);
|
|
||||||
|
|
||||||
// Now convert it, using UTF-16 -> UTF-8
|
|
||||||
dest := UTF16ToUTF8(widestr);
|
|
||||||
{$ifdef PASWSTRING_SUPPORT_NONUTF8_ANSISTRING}
|
{$ifdef PASWSTRING_SUPPORT_NONUTF8_ANSISTRING}
|
||||||
// And correct to the real Ansi encoding
|
// And correct to the real Ansi encoding
|
||||||
dest := ConvertEncoding(dest, EncodingUTF8, GetDefaultTextEncoding());
|
dest := ConvertEncoding(dest, EncodingUTF8, GetDefaultTextEncoding());
|
||||||
@ -331,10 +328,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Ansi2UnicodeMove(source:pchar;var dest:UnicodeString;len:SizeInt);
|
procedure Ansi2UnicodeMove(source:pchar;var dest:UnicodeString;len:SizeInt);
|
||||||
|
{$IFDEF PASWSTRING_SUPPORT_NONUTF8_ANSISTRING}
|
||||||
var
|
var
|
||||||
ansistr: ansistring;
|
ansistr: ansistring;
|
||||||
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
{$ifdef PASWSTRING_VERBOSE}WriteLn('Ansi2UnicodeMove START');{$endif}
|
{$ifdef PASWSTRING_VERBOSE}WriteLn('Ansi2UnicodeMove START');{$endif}
|
||||||
|
{$IFDEF PASWSTRING_SUPPORT_NONUTF8_ANSISTRING}
|
||||||
|
if NeedRTLAnsi then begin
|
||||||
// Copy the originating string taking into account the specified length
|
// Copy the originating string taking into account the specified length
|
||||||
SetLength(ansistr, len);
|
SetLength(ansistr, len);
|
||||||
System.Move(source^, ansistr[1], len);
|
System.Move(source^, ansistr[1], len);
|
||||||
@ -345,6 +346,12 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
// Now convert it, using UTF-8 -> UTF-16
|
// Now convert it, using UTF-8 -> UTF-16
|
||||||
dest := UTF8ToUTF16(ansistr);
|
dest := UTF8ToUTF16(ansistr);
|
||||||
|
end else begin
|
||||||
|
dest := UTF8ToUTF16(source,len);
|
||||||
|
end;
|
||||||
|
{$ELSE}
|
||||||
|
dest := UTF8ToUTF16(source,len);
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function UpperUnicodeString(const s : UnicodeString) : UnicodeString;
|
function UpperUnicodeString(const s : UnicodeString) : UnicodeString;
|
||||||
|
Loading…
Reference in New Issue
Block a user