SetCodePage in older FPC 3.0.4

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

SetCodePage in older FPC 3.0.4

AlexeyT
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}?

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

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

--
Regards,
Alexey

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SetCodePage in older FPC 3.0.4

Jonas Maebe-3
On 2019-05-29 00:58, Alexey Tor. wrote:
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SetCodePage in older FPC 3.0.4

AlexeyT
 > 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?

user@PC:~/fpcupdeluxe/fpcsrc/packages/rtl-unicode/src/inc$ ls cp*
cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp

and

user@PC:~/fpcupdeluxe/fpcsrc/rtl/ucmaps$ 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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SetCodePage in older FPC 3.0.4

Michael Van Canneyt


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?
>
> user@PC:~/fpcupdeluxe/fpcsrc/packages/rtl-unicode/src/inc$ ls cp*
> cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp
>
> and
>
> user@PC:~/fpcupdeluxe/fpcsrc/rtl/ucmaps$ 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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SetCodePage in older FPC 3.0.4

Michael Van Canneyt


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?
>>
>> user@PC:~/fpcupdeluxe/fpcsrc/packages/rtl-unicode/src/inc$ ls cp*
>> cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp
>>
>> and
>>
>> user@PC:~/fpcupdeluxe/fpcsrc/rtl/ucmaps$ 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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SetCodePage in older FPC 3.0.4

Tomas Hajny-2
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?
>>>
>>> user@PC:~/fpcupdeluxe/fpcsrc/packages/rtl-unicode/src/inc$ ls cp*
>>> cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp
>>>
>>> and
>>>
>>> user@PC:~/fpcupdeluxe/fpcsrc/rtl/ucmaps$ 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: SetCodePage in older FPC 3.0.4

Michael Van Canneyt


On Wed, 29 May 2019, Tomas Hajny wrote:

> 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?
>>>>
>>>> user@PC:~/fpcupdeluxe/fpcsrc/packages/rtl-unicode/src/inc$ ls cp*
>>>> cp895.pas  cp932.pas  cp936.pas  cp949.pas  cp950.pas cpbuildu.pp
>>>>
>>>> and
>>>>
>>>> user@PC:~/fpcupdeluxe/fpcsrc/rtl/ucmaps$ 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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal