mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 12:19:18 +02:00
Added initial utf-8 widestring manager activated by -dUseUTF8WString
git-svn-id: trunk@13329 -
This commit is contained in:
parent
771a6bde13
commit
ba95497e04
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -3272,6 +3272,7 @@ lcl/themes.pas svneol=native#text/pascal
|
||||
lcl/tmschema.pas svneol=native#text/pascal
|
||||
lcl/toolwin.pp svneol=native#text/pascal
|
||||
lcl/translations.pas svneol=native#text/pascal
|
||||
lcl/utf8wstring.pas -text
|
||||
lcl/utrace.pp svneol=native#text/pascal
|
||||
lcl/widgetset/README.txt svneol=native#text/plain
|
||||
lcl/widgetset/wsactnlist.pp svneol=native#text/pascal
|
||||
|
@ -63,7 +63,8 @@ uses
|
||||
WSToolwin,
|
||||
WSProc,
|
||||
WSDesigner,
|
||||
DefaultTranslator;
|
||||
// Other units
|
||||
DefaultTranslator, utf8wstring;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -33,6 +33,9 @@ interface
|
||||
{$endif}
|
||||
|
||||
uses
|
||||
{$ifdef UseUTF8WString}
|
||||
utf8wstring,
|
||||
{$endif}
|
||||
Types, Classes, SysUtils, Math, LCLStrConsts, LCLType, LCLProc, LMessages,
|
||||
GraphType, GraphMath, Themes;
|
||||
|
||||
|
62
lcl/utf8wstring.pas
Normal file
62
lcl/utf8wstring.pas
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
/***************************************************************************
|
||||
utf8wstring.pas
|
||||
-----------
|
||||
UTF-8 Widestring manager
|
||||
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
*****************************************************************************
|
||||
* *
|
||||
* This file is part of the Lazarus Component Library (LCL) *
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
|
||||
Ensures that we have a reliable encoding for ansistrings (UTF-8 Encoding),
|
||||
until a new type for utf-8 strings is created.
|
||||
}
|
||||
unit utf8wstring;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
procedure UTF8Wide2AnsiMove(source:pwidechar;var dest:ansistring;len:SizeInt);
|
||||
procedure UTF8Ansi2WideMove(source:pchar;var dest:widestring;len:SizeInt);
|
||||
|
||||
implementation
|
||||
|
||||
procedure UTF8Wide2AnsiMove(source: pwidechar; var dest: ansistring; len: SizeInt);
|
||||
var
|
||||
Buffer: WideString;
|
||||
begin
|
||||
Buffer := Copy(source, 1, len);
|
||||
dest := UTF8Encode(Buffer);
|
||||
end;
|
||||
|
||||
procedure UTF8Ansi2WideMove(source: pchar; var dest: widestring; len: SizeInt);
|
||||
var
|
||||
Buffer: ansistring;
|
||||
begin
|
||||
Buffer := Copy(source, 1, len);
|
||||
dest := UTF8Decode(Buffer);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
Widestringmanager.Wide2AnsiMoveProc := @UTF8Wide2AnsiMove;
|
||||
Widestringmanager.Ansi2WideMoveProc := @UTF8Ansi2WideMove;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user