ASC() Returns Incorrect Values for Extended Characters

ID: Q99083

The information in this article applies to:

SUMMARY

Page L3-205 of the "Language Reference" manual states that every character has a unique ASCII value in the range from 0 to 255 and that the ASC() function can be used to return the ASCII value for any character.

However, in FoxPro for Windows, the ASC() function returns incorrect values for characters in the extended character set.

To return correct values for the extended character set in FoxPro for Windows, use the ANSITOOEM() function as follows:

   ?ASC(ANSITOOEM(' '))

MORE INFORMATION

Steps to Reproduce Behavior

1. In the FoxPro for Windows Command window, type:

      ?ASC('

2. Hold down the ALT key and type a number between 128 and 255 using
   the numeric keypad.

3. Type the following and press ENTER:

      ')

   FoxPro for Windows returns a different value than the one you
   typed.

This behavior arises because the MS-DOS product uses the ASCII character set and the Windows product uses the ANSI character set. When the ASC() function is used in FoxPro for Windows, correct values will be returned only for characters in the 0-127 range.

REFERENCES

For more information, see pages L3-191 and L3-205 in the "Language Reference" for FoxPro version 2.5.

Additional reference words: FoxWin 2.50 2.50a character value documentation error high order KBCategory: kbprg KBSubcategory: FxprgGeneral

Last Reviewed: June 27, 1995