[fpc-devel] new string - question on usage

Martin lazarus at mfriebe.de
Tue Oct 11 00:10:26 CEST 2011


On 10/10/2011 22:36, Jonas Maebe wrote:
> On 10 Oct 2011, at 23:11, Martin wrote:
>
>> On 10/10/2011 21:56, Jonas Maebe wrote:
>>>> 2- It should have (dont know if currently has) a compiler switch to change the default code page to UTF8 or whatever, so all variables with type String will map to UTF8String.
>>> I doubt that such a feature will be added. If you want that, declare your own string type with whatever default code page you want to use and use that type everywhere.
>>>
>> But that will always just push the issue to another location.
> Changing the default code page of the "string" type in a particular unit via a compiler switch would not change that (a program usually also uses units that have been compiled earlier on, and those may then have used a different default code page).
I wasn't askin for changing the default.

just for how to do

procedure foo(x: utf8string); begin end;

var a: string; //ansistring, but contains already utf8

foo(a); // do not convert

>> And what happens if an app did read data from some external source (serial port) and then wants to declare what encoding it is?
> http://docwiki.embarcadero.com/VCL/en/System.SetCodePage
>
>
I hadn't seen that.

That may help. Though not the best solution...

I can call it before calling the "foo" proc. But I must revert it 
afterwards, or at sometime later, the string will be translated, when it 
will be used in a normal string again (yet expected to keep being utf8..

Yes, I know, what i want to do, is not what it was designed for. 
ultimately a huge update to the entire source will be needed... but now 
I need a temporary solution until then



More information about the fpc-devel mailing list