ASC() Returns Incorrect Values for Extended Characters

Last reviewed: June 27, 1995
Article ID: Q99083
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.