Sign in Join

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

Mailing lists / fpc-devel / 2017-12

String constant without code page

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Petr Kristan

Hi.

I compile whole project with -FcUTF8, but sometimes should be useful to define string constant with CP_NONE to prevent conversions.

Example:

DefaultSystemCodePage:=1250
variable s contains text with cp=1250
s := s + '#'; //conversion because '#' has cp=65001

Is possible to define '#' without cp?
Or is possible to do fast string concatenation without conversion?

Thanks
Petr

Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401 Czech Republic (Eastern Europe) fax: +420 461101481

Reply by email

Sven Barth

Am 14.12.2017 09:37 schrieb "Petr Kristan" :

Hi.

I compile whole project with -FcUTF8, but sometimes should be useful to define string constant with CP_NONE to prevent conversions.

Example:

DefaultSystemCodePage:=1250
variable s contains text with cp=1250
s := s + '#'; //conversion because '#' has cp=65001

Is possible to define '#' without cp?
Or is possible to do fast string concatenation without conversion?

A concatenation is done without conversion if all strings have the same code page. You can enforce the code page using SetCodePage() which has a parameter to not convert the string to that code page. You can retrieve the code page using StringCodePage().

See also:
https://www.freepascal.org/docs-html/rtl/system/setcodepage.html https://www.freepascal.org/docs-html/rtl/system/stringcodepage.html

Regards,
Sven

Reply by email