4747
|
|
|
CODE PAGE & COLLATION SEQUENCE |
- You wish it (or not), always current CP is installed, and you can see it,
by using function CPCURRENT() [as addition: CPCURRENT(1) - main at OS,
CPCURRENT(2) - alternate at OS]. And how it can be installed?
- CP is installed during of loadings FPD/VFP itself and takes it from OS, or
from the Config.fp(w) file or immediately from exe / in the current
directory of programm / indicated through a parameter for Config.fp(w). The
fact only, that CP, so or something differently, is installed in any case.
- I shall repeat, that the current installation CP can be checked through
function CPCURRENT() [and for Russian: main - Windows - 1251, alternate -
DOS - 866]
- On any case check up ?SET('CPCOMPILE') and see also: SET CPCOMPILE TO...,
COMPILE ... AS...
- During reading of any dbf-based file from its header read its CP, i.e. in
which datas in the file ostensibly are stored.
- If CP-file != CPCURRENT() - the implicit transformation is made, ...and as
I understand, still during reading from file buffers into memory.
- If CP-file == CPCURRENT() - it is obvious, that of any transformations is
not made. It is obvious, that in this case time on transformations is not
lost.
- Separately for fields of the file, you can bar these implicit
transformations, by using SET NOCPTRANS TO [FieldName1[,FieldName2...]] or
define field type as Character(Binary)/Memo(Binary)
- It is necessary to mark, that if the CP is not installed in file header,
i.e. 0, the transformations in 1251 (i.e. for us, Russian is current) will
be executed incorrectly, that it is possible to observe, for example, for
attempt to insert into libraries (with not installed CP) the Russian
letters. Or it is simple, for view anyone of FPD-dbf-file with CP = 0 in
SHARED mode from Browse under VFP.
- At last, if the file opens in a EXCLUSIVE-mode, and CP of the file = 0,
and SET CPDIALOG ON, - that arises CODE PAGE dialogue for installation of
the code page, ostensibly in which the datas [are stored if precisely know
it :-)] (separately this dialogue can be called by function GETCP()).
- Well and certainly, always you can use function CPCONVERT() for
transformation manually of string-lines (that by the way (malapropos :-() it
is necessary to do in VFP, during reading FPD-dbf-file, for which is not
installed CP by whatever reasons).
- At first, in case attempt to use dbf-based file with not installed CP
(CP=0) in EXCLUSIVE-mode and if SET('CPDIALOG') = ON
- Secondly, manually, by using the utility HOME()+"\Tools\Cpzero\Cpzero.prg"
with syntax: DO ("<FullPath>Cpzero.prg") WITH "<FullPath>MyFile", <nNewCP>
- Well and, thirdly, immediately on creation of dbf-based file, - CP takes
from CPCURRENT()
- At first, through the menu item Tools\Options...[Data] Collation Seqience
+[Set As Default] (Registers in the System Register)
- Secondly, from Config.fp(w). For example, COLLATE="RUSSIAN" see also Notes about CODE PAGE, Setting
- Well and, thirdly, manually from a code. For example, SET COLLATE TO
"RUSSIAN" for current DataSession.
- The Collation Seqience registers as a property for tag of CDX-files on a
moment of their creation/modification (takes from SET('COLLATE') from
current DataSession)
- To check up Collation Seqience of an index it is possible by function
IDXCOLLATE()
- It is necessary to mark, that reset Collation Seqience by SET COLLATE TO
<Something> does not influence on the already existing indexes
- Collation Seqience supports a correct sequence of ordering in operations
of indexation and sorting of datas.
-
- "MACHINE"- supports compatibility with Xbase-seqience,
- "GENERAL" - for US and Western Europe in earlier than 2.5 versions it is
necessary obviously to use UPPER()/LOWER(), in later ver. transformation in
UPPER() is carried out automatically [last correctly and for "RUSSIAN" :-(]
-
- During fulfilment SQL-SELECT, in case of creation of a temporary index
for optimization of the request, VFP has an error: - Here Mike's comment in
this occasion:
... As I remember, it has appeared in any VFP3[ab],
Then _it_ have fixed, then it again has appeared in any VFP5 and ...
HURRAH! Fixed on-silent in VFP6 SP5!
And in VFP7 _it_ from the very outset was not presented...
Mike Korneev
см. Mike's test demonstratings of an error.
As is told above, only by a modification of an index, besides Collation
Seqience takes from SET('COLLATE') from current DataSession
**** start of any.prg
if cpcur()!=1251
activate screen
clear
? 'Please set in CONFIG.FPW'
? ' CodePage=1251'
?? chr(7)
return
endif
CLOSE DATA ALL
=CreateData()
set collate to 'Russian'
=RunQuery()
set collate to 'Machine'
=RunQuery()
move window (wontop()) by 0,20
*************
function RunQuery
select * from tbl1 where TblID not in (select TblID from tbl2) ;
into cursor ('Collate_'+set('collate'))
browse nowait
***********
function CreateData
close data
create cursor tbl1 (TblID I)
create cursor tbl2 (TblID I)
for i=1 TO 1000
insert into tbl1 values (i)
insert into tbl2 values (i)
endfor
**** end of any.prg
See also in MSDN:
- Q129631 "Understanding Code Pages in Visual FoxPro"
- Q181085 "BUG: SET COLLATE & Queries - Additional Problem Scenarios"
For version VFP 5.0 and less... and for Microsoft Visual FoxPro ODBC Driver,
need file FoxPro.int (Code page and collation sequence file) in
Windows\System[32]
See also:
Q141913 PRB: Error 1915 - Collating Sequence "" is not found
Q138614 Description of Foxpro.int Table
Q150502 PRB: Collating Sequences Not Displayed in the Setup Dialog
http://msdn.microsoft.com/vfoxpro/downloads/download.asp?ID=027 - Visual
FoxPro 6.0 ODBC Driver FoxPro.int Resource File