View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0020258FPCDocumentationpublic2011-09-15 14:342012-04-22 00:57
ReporterNashev 
Assigned To 
PrioritynormalSeveritymajorReproducibilityN/A
StatusfeedbackResolutionopen 
PlatformOSOS Version
Product Version2.4.4Product Build 
Target VersionFixed in Version 
Summary0020258: Use types UTF8String, PUTF8Char etc instead types string and PChar @ work with UTF8 encoded strings and chars
DescriptionIt need to allow strict type checking and for improve autodocumentation ability of RTL sources.

I'm about all functions, procedures, methods and properties like:

function UnicodeToUtf8(Dest: PUTF8Char; Source: PWideChar; MaxBytes: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
function UnicodeToUtf8(Dest: PUTF8Char; MaxDestBytes: SizeUInt; Source: PWideChar; SourceChars: SizeUInt): SizeUInt;
function Utf8ToUnicode(Dest: PWideChar; Source: PUTF8Char; MaxChars: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
function Utf8ToUnicode(Dest: PWideChar; MaxDestChars: SizeUInt; Source: PUTF8Char; SourceBytes: SizeUInt): SizeUInt;

Also in Lazarus - TOpenDialog.FileName etc must be TUTF8String.
TagsNo tags attached.
FPCOldBugId0
Fixed in Revision
Attached Files

- Relationships

-  Notes
(0051858)
Nashev (reporter)
2011-09-15 14:48

see also similar Lazarus LCL issue 0020259
(0051881)
Marco van de Voort (manager)
2011-09-15 22:21

Since utf8* are currently a 100% type alias for the other types, typesafety will not be affected -> changing to documentation
(0051882)
Jonas Maebe (manager)
2011-09-15 22:55

putf8char does not exist. And if it is ever introduced, it will also be a plain alias for pansichar.

Furthermore, bug reports simply mentioning "all functions, procedures, methods and properties like ..." are not very useful. Please provide a patch to add the required types and to change the relevant signatures.
(0051883)
Nashev (reporter)
2011-09-15 23:02
edited on: 2011-09-15 23:34

there are declared UTFString = type of ansistring;
it is not equal UTFString = ansistring;
it is force compiler to produce messages about inconsistency when mistyping! And it s good.

With PUTF8Char must be too.

And "changing to documentation" it is not enough! First documentation for programmer - it is sources, and type for string with stable single byte ANSI chars MUST be differ from type for strings with mixed length chars.

(0051886)
Jonas Maebe (manager)
2011-09-15 23:32

> there are declared UTFString = type of string;
> it is not equal UTFString = string;
> it is force compiler to produce messages about
> inconsistency when mistyping! And it s good.

That is not true. The only thing that does is to allow overloading between string and utf8string. Those types are still considered 100% compatible and the compiler won't give any error, warning or hint when passing one of these types to the other.

> With PUTF8Char must be too.

That will also only allow overloading.

> And "changing to documentation" it is not enough!

What Marco meant is that these code changes themselves are documentation changes. They don't change the functionality.

Again: a patch is welcome.
(0051887)
Nashev (reporter)
2011-09-15 23:35

I'n not so familiar with creating patches yet. But i'l try.
(0051889)
Nashev (reporter)
2011-09-15 23:46

I try to search PUTF8Char at home computer, but found only this:

TUTF8Char = String[4]; in http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/objpas/utf8bidi.pp?view=markup [^]
UTF8Char = UInt8; in http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/univint/src/MacTypes.pas?view=markup [^]

But on work computer i had successfully compiled unit with declaration6 modified to function UnicodeToUtf8(Dest: PUTF8Char; Source: PWideChar; MaxBytes: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}

Tomorrow i will check it.
(0051890)
Jonas Maebe (manager)
2011-09-16 00:01

Maybe Lazarus declares the putf8char type somewhere.
(0051906)
Nashev (reporter)
2011-09-16 10:48

No, sorry. About PUTF8Char it is my mistake - I've modify wstringh.inc, but my program was compiled with ustringh.inc, which contain some functions but with PUnicodeChar instead of PWideChar.
(0058861)
Marco van de Voort (manager)
2012-04-22 00:57

Relevancy should be reviewed in the light of 2.7.1 changes in time.

utf8string is now a separate type?

- Issue History
Date Modified Username Field Change
2011-09-15 14:34 Nashev New Issue
2011-09-15 14:48 Nashev Note Added: 0051858
2011-09-15 21:38 Marco van de Voort Project FPC => Lazarus
2011-09-15 21:39 Marco van de Voort Project Lazarus => FPC
2011-09-15 22:21 Marco van de Voort Note Added: 0051881
2011-09-15 22:22 Marco van de Voort FPCOldBugId => 0
2011-09-15 22:22 Marco van de Voort Category RTL => Documentation
2011-09-15 22:55 Jonas Maebe Note Added: 0051882
2011-09-15 22:55 Jonas Maebe Status new => feedback
2011-09-15 23:02 Nashev Note Added: 0051883
2011-09-15 23:32 Jonas Maebe Note Added: 0051886
2011-09-15 23:34 Nashev Note Edited: 0051883
2011-09-15 23:35 Nashev Note Added: 0051887
2011-09-15 23:46 Nashev Note Added: 0051889
2011-09-16 00:01 Jonas Maebe Note Added: 0051890
2011-09-16 10:48 Nashev Note Added: 0051906
2012-04-22 00:57 Marco van de Voort Note Added: 0058861



MantisBT 1.2.12[^]
Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker