[Lazarus] Resource strings and newline

Péter Gábor ptrg at freemail.hu
Thu Jun 19 08:27:27 CEST 2014


PO-reader works system specific so \n will be converted to #10 on linux
and #13#10 on windows, etc.

But what does PO-writer with #10, #13 and #13#10 in a single
resourcestring? Like this: 'How'#10'many'#10'lines'#13#10'here?'

It converts only the system specific LineEnding to \n or it converts all
possible (other systems' LineEnding) values to \n?

The second ("all-are-the-same") approach is used by ShowMessage().
The following will have 3 line breaks inside the string on all operating
systems:
	ShowMessage('How'#10'many'#13'lines'#13#10'here?');

2014-06-19 07:07 keltezéssel, Péter Gábor írta:
> I asked about different LineEndigs because of the resourcestrings which
> are written by developers working on different operating systems.
> They may put different LineEnding in resourcestrings if they don't use
> the LineEnding constant, but writing #13#10 or #10 or #13 as it is usual
> on their system. In this case the compiler on an other system may not
> accept the hardcoded line ending as it is wished by the developer.
> 
> If the string 'Linux#10is great!' will be compiled on Linux it will
> become 'Linux \n is great!' but when compiling on windows it will not
> have the \n in it.
> 
> If the string is written like this: 'Linux'+LineEnding+' great!' will be
> compiled on both systems to 'Linux \n is great!'
> 
> Using #10 instead of +LineEnding+ is faster so I think a lot of
> developers will use this to insert new line marker in their strings.
> 
> 2014-06-18 19:56 keltezéssel, Sven Barth írta:
>> Am 18.06.2014 18:32 schrieb "Péter Gábor" <ptrg at freemail.hu
>> <mailto:ptrg at freemail.hu>>:
>>>
>>>
>>>
>>> 2014-06-18 09:44 keltezéssel, Mattias Gaertner írta:
>>>> In the old days special characters were not converted properly.
>>>>
>>>> I just tested:
>>>>
>>>> 'A'#10'BC' is converted to
>>>> msgid ""
>>>> "A\n"
>>>> "BC\n"
>>>>
>>>> Note the new line behind BC. When this is fixed, I can adapt the 'Make
>>>> resourcestring dialog'.
>>>>
>>>> Also all line breaks (#10, #13, #13#10) are converted to \n and on
>>>> loading to the system line break. That's ok for all strings
>>>> passed to the LCL, but all other must be checked manually.
>>>>
>>>> Mattias
>>>
>>> What is about that all systems has its own LineEnding?
>>> eg.: a single #10 or a single #13 is not marking EOL on windows, #13 is
>>> not marking EOL on Linux, etc.
>>
>> \n is automatically converted using the LineEnding variable when the
>> PO-reader parses it. So you are only out of luck if you want a
>> resourcestring that should contain e.g. #13#10 on e.g. a Linux system.
>>
>> Regards,
>> Sven
> 

-- 
Péter Gábor
ptrg at freemail.hu




More information about the Lazarus mailing list