Sign in Join

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

Mailing lists / fpc-pascal / 2019-05

SetCodePage in older FPC 3.0.4

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Jonas Maebe
to Alexey Tor.
Alexey Tor. wrote 5 lines
I am making small unit https://github.com/alexey-t/aencoding so I need to know: a) will it work on FPC 3.0.4? do I need to use {$ifdef}?

It will probably (not) work the same under FPC 3.0.4 and trunk. No guarantees though.

b) my trick to set CP_UTF8 at the end of nnnnFromTo function is ok?

It's not ok. It will at leas break when trying to write such a string, or when assigning it to a unicodestring or widestring, or when assigning it to a typed ansistring with a different code page than UTF-8 or DefaultSystemCodePage.

c) what encoding numbers (e.g. 936, 950) exist in FPC 3.3 but didn't exist in FPC 3.0.4?

FPC generally uses system library functions for the conversion, so it does not depend on the FPC version. The only exception is if you use the fpwidestring unit. In that case, the supported code pages depend on which extra units from packages/rtl-unicode you include. I don't know which code page(s) it supports by default.

Jonas

Reply by email

AlexeyT
to Jonas Maebe
FPC generally uses system library functions for the conversion, so it

does not depend on the FPC version.

But FPC has such files. Are they used in SetCodePage code?

ls cp*
cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp

and

ls
8859-10.txt  8859-2.txt  8859-9.txt  cp1256.txt  cp850.txt cp862.txt  cp895.txt
8859-11.txt  8859-3.txt  cp1250.txt  cp1257.txt  cp852.txt cp863.txt  cp932.txt
8859-13.txt  8859-4.txt  cp1251.txt  cp1258.txt  cp855.txt cp864.txt  cp936.txt
8859-14.txt  8859-5.txt  cp1252.txt  cp3021.txt  cp856.txt cp865.txt  cp949.txt
8859-15.txt  8859-6.txt  cp1253.txt  cp437.txt   cp857.txt cp866.txt  cp950.txt
8859-16.txt  8859-7.txt  cp1254.txt  cp737.txt   cp860.txt cp869.txt  koi8-r.txt
8859-1.txt   8859-8.txt  cp1255.txt  cp775.txt   cp861.txt cp874.txt  koi8-u.txt

Regards, Alexey

Reply by email

Michael Van Canneyt
to AlexeyT
AlexeyT wrote 11 lines
> FPC generally uses system library functions for the conversion, so it does not depend on the FPC version. But FPC has such files. Are they used in SetCodePage code? ls cp* cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp and ls

These files are not used, they predate the fpWidestring unit, they are for the charset unit, which can be used to manually convert codepages.

Michael.

Reply by email

Michael Van Canneyt
to Michael Van Canneyt
Michael Van Canneyt wrote 19 lines
On Wed, 29 May 2019, AlexeyT wrote: >> FPC generally uses system library functions for the conversion, so it > does not depend on the FPC version. > > But FPC has such files. Are they used in SetCodePage code? > > ls cp* > cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp > > and > > ls These files are not used, they predate the fpWidestring unit, they are for the charset unit, which can be used to manually convert codepages.

Correction: if you use the fpwidestring unit, these charset units are used.

Michael.

Reply by email

Tomas Hajny
to Michael Van Canneyt
Michael Van Canneyt wrote 22 lines
On Wed, 29 May 2019, Michael Van Canneyt wrote: > On Wed, 29 May 2019, AlexeyT wrote: > >>> FPC generally uses system library functions for the conversion, so >>> it >> does not depend on the FPC version. >> >> But FPC has such files. Are they used in SetCodePage code? >> >> ls cp* >> cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp >> >> and >> >> ls > > These files are not used, they predate the fpWidestring unit, they are > for the > charset unit, which can be used to manually convert codepages. Correction: if you use the fpwidestring unit, these charset units are used.

Well, I believe that it's still a bit imprecise. ;-) My understanding is that a programmer deciding to use fpwidestring may decide on the set of character mappings to be supported out of the box in his program. That may be done in two ways. One is by including a unit for a particular character set (e.g. fpcsrc/rtl/charmaps/cp1252.pas or fpcsrc/packages/rtl-unicode/src/inc/cp932.pas) or a set of character sets (fpcsrc/rtl/charmaps/cpall.pas and/or
fpcsrc/packages/rtl-unicode/src/inc/cpbuildu.pas) in the uses clause of one of the project source files. The other is by loading a binary file (install/unicode/charset/*.bcm) dynamically at runtime (LoadBinaryUnicodeMapping in fpcsrc/rtl/inc/charset.pp). Both the units and the binary files are generated from the *.txt files using tools included with FPC.

Tomas

Reply by email

Michael Van Canneyt
to Tomas Hajny
Tomas Hajny wrote 37 lines
On 2019-05-29 12:19, Michael Van Canneyt wrote: > On Wed, 29 May 2019, Michael Van Canneyt wrote: >> On Wed, 29 May 2019, AlexeyT wrote: >> >>>> FPC generally uses system library functions for the conversion, so >>>> it >>> does not depend on the FPC version. >>> >>> But FPC has such files. Are they used in SetCodePage code? >>> >>> ls cp* >>> cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp >>> >>> and >>> >>> ls >> >> These files are not used, they predate the fpWidestring unit, they are >> for the >> charset unit, which can be used to manually convert codepages. > > Correction: if you use the fpwidestring unit, these charset units are > used. Well, I believe that it's still a bit imprecise. ;-) My understanding is that a programmer deciding to use fpwidestring may decide on the set of character mappings to be supported out of the box in his program. That may be done in two ways. One is by including a unit for a particular character set (e.g. fpcsrc/rtl/charmaps/cp1252.pas or fpcsrc/packages/rtl-unicode/src/inc/cp932.pas) or a set of character sets (fpcsrc/rtl/charmaps/cpall.pas and/or fpcsrc/packages/rtl-unicode/src/inc/cpbuildu.pas) in the uses clause of one of the project source files. The other is by loading a binary file (install/unicode/charset/*.bcm) dynamically at runtime (LoadBinaryUnicodeMapping in fpcsrc/rtl/inc/charset.pp). Both the units and the binary files are generated from the *.txt files using tools included with FPC.

Yes. See
https://www.freepascal.org/docs-html/current/rtl/fpwidestring/index.html

Michael.

Reply by email