Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table does not Save Character Correctly, why??

Status
Not open for further replies.

Serincino

Programmer
Jun 13, 2003
61
US
My program uses some special characters that need to be saved into a Table. Here is an example.

r = chr(169)
replace table.field with r

for anyone that doesn't know ASCII 169 is the copyright symbol.
When I go to pull this out of the table a different character is pulled, I've also looked in the table in a browse window and the different letter is diplayed as well.


test = table.field
? asc(test) && displays '99'


Can some one please help me solve this problem. I understand that it's easy enough just right an if statement for the one character, but since ASCII 99 is 'c' and I save multiple characters with this one character it not as simple. Also below is a list of all the ascii characters the table does not store properly.


128-148,150-159,164,167-169,173-175,179-180,182,184-185,190,192-195,200,202-208,210-213,215-219,221-222,227,240,245,248,253-254

This is a very important part of my program. Thanks for any help you all give.

-Serincino

If you see a programmer in the office before 9am, they probably never left.
 
Serincino,

r = chr(169)
replace table.field with r


I just tried that code, and it works OK. Could it be a code page issue? If you created the table under a different code page AND you don't have the code page set correctly in VFP, that could possibly explain it.

Try using CPCURRENT() and CPDBF() to see if the code page of the table matches that of the session.

Mike

Mike Lewis
Edinburgh, Scotland
 
Serincino

This may not be practical but have you considered storing only the ASCII value in the field.

r = [CHR(169)]
CREATE CURSOR test (cline C(254))
INSERT INTO test (cline) VALUES (SUBST(r,5,3))
? EVALUATE([CHR(] + (cline) +[)])

will display the ASCII value correctly.

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
thanks for all your help. Mike it was the codepage values, Using set nocptrans to table.field worked, but is there a way to completely set the entire table to code 1252, the current value is 453.

Thanks,

Serincino

If you see a programmer in the office before 9am, they probably never left.
 
Yes,
You can change a table's code page using the "obviously" named program CPZERO.PRG. Try:
Code:
DO (HOME()+"tools\cpzero\cpzero.prg") WITH dbfname, 1252
Rick


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top