Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-03

Very simple questions about Widestring on Linux

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Léo Willian Kölln

I´m Working on a project of a program that will run on Windows and Linux. The binary to the windows will be compiled using Delphi, and for Linux using FPC. (This is not the question)

All the strings on the code are Widestrings (yes!). On Windows i have specific functions to call using Widestrings (functions with the postfix W).

No problems so far, but when i want to implement my functions using the RTL, i just see arguments, parameters and returns of String. As far i´ve read, they are aways Ansistrings, i´m right? Or i need inform the compiler of this? (Q1)

To convert to Widestrings, i need include the unit "cwstring". Where? Only at the main unit, or on every unit where an RTL function is called? (Q2)
The conversion is transparent, in both ways? (Q3)

And for a stupid question:
If my host (linux) machine is using, for example, an ISO8859-1 coding (file names, etc...) or even a more exotic one.
The conversion will be transparent, in both ways? (Q4)

The answers will help a lot, maybe a very objective Wiki entry about this will help a lot of people, because i read many threads on the list, a lot of text on the Wiki but all i find is discussion about the types of string, what will be better if default, etc (all discussions are valids, but is not what i was looking for).

Thanks in advance and sorry the bad English!

Léo

Reply by email

Jonas Maebe
to Léo Willian Kölln
Léo Willian Kölln wrote
No problems so far, but when i want to implement my functions using the RTL, i just see arguments, parameters and returns of String. As far i´ve read, they are aways Ansistrings, i´m right? Or i need inform the compiler of this? (Q1)

It depends on which unit. Everything in sysutils accepts/returns ansistrings, yes. Older units, like the Dos unit, accept/return shortstrings (these also use the ansi-encoding though). You cannot change this using a compiler switch, as it is part of the way the unit's interfaces are defined.

To convert to Widestrings, i need include the unit "cwstring". Where? Only at the main unit, or on every unit where an RTL function is called? (Q2)

Only in your main program.

The conversion is transparent, in both ways? (Q3)

Yes.

And for a stupid question: If my host (linux) machine is using, for example, an ISO8859-1 coding (file names, etc...) or even a more exotic one. The conversion will be transparent, in both ways? (Q4)

Characters not representable in the "ansi" encoding of the machine, will get lost when converting from widestring to ansistring. This will be solved once we implement support for Delphi2009's new "ansistring- with-codepage" type.

Jonas

Reply by email