Megosztás a következőn keresztül:


Specifying the Code Page of a .dbf File

When you create .dbf files, Visual FoxPro automatically gives them code page marks so that you can tell which code pages they use. However, if you use .dbf files from previous versions of FoxPro, they might not have code page marks.

You can determine whether a .dbf file has a code page mark by using the CPDBF( ) function after opening the file or by having Visual FoxPro check when you open the file.

To check for code page marks automatically

  1. From the Tools menu, choose Options.

  2. Select the Data tab.

  3. Set the Prompt for code page check box, if it's not already set.

    To save this setting for future sessions of Visual FoxPro, choose Set as Default.

    Tip   Instead of setting the Prompt for code page check box, you can use the SET CPDIALOG command to check for code pages.

If a file doesn't have a code page mark, you must add a mark, as described in the following section.

Adding Code Page Marks

If you use a .dbf file from a previous version of FoxPro, the file might not have a code page mark; without such a mark, the file might not display properly. If automatic code page checking is enabled, when you open the file you can tell if it has a code page mark. If it doesn't have one, you can add one.

To manually add a code page mark to a .dbf file

  1. Ensure automatic code page checking is in effect (see the previous procedure).

  2. Open the file.

    If the file doesn't have a code page mark, the Code Page dialog box appears.

  3. Choose the appropriate code page.

  4. View the file to see if you assigned the proper code page.

    If you can't see some of the data, or if you can't recognize some of it, the code page is not correct.

  5. If the code page is incorrect, remove the code page mark by using the CPZERO program in the Visual FoxPro Tools\Cpzero directory.

  6. Repeat this procedure until the code page is correct.

    Note   Text files such as program (.prg) and query (.qpr) files don't have code page marks. This means that you can't tell which code pages the files use. However, if you include such files in a project, the project can keep a record of the code pages used. For details, see Specifying the Code Page of a Text File.

Removing Code Page Marks

If a .dbf file doesn't display properly, it might have the wrong code page mark. You can remove the code page mark with the CPZERO program located in Tools\Cpzero. Running CPZERO sets the code page to 0, meaning none.

To remove a code page mark

  • Run CPZERO using the following syntax:

    DO CPZERO WITH "filename", 0

    Note   When you remove the code page mark of a .dbf file, the data in the file doesn't change. To change the code page of the data, you must mark the file with the proper code page.

Changing Code Page Marks

You can change the code page of a .dbf file by removing its code page mark and then adding a new one, by copying the file to another file, or by using the CPZERO program.

To change the code page of a .dbf file by copying the file

  • Use the COPY TO command, specifying the target code page with the AS clause. (To set the code page to the current system code page, omit the AS clause.)

    For example, to copy Test.dbf to Test866.dbf, while changing the code page to 866, use the following commands:

    USE TEST.DBF
    COPY TO TEST866.DBF AS 866
    

When the COPY TO completes, the data in the resulting file will have the new code page.

To change a code page mark using CPZERO

  • Run CPZERO using the following syntax:

    DO CPZERO WITH "filename", newCodePage

    Note   Some characters cannot be translated between code pages successfully. In addition, some code page translations aren't supported by Visual FoxPro. Always check the results of a code page change to be sure that your data has been translated successfully.

See Also

Code Pages in Visual FoxPro | Specifying the Code Page of a Text File | Developing International Applications | Determining the Code Page of a Project File | Specification of Code Pages for Variables