PRB: UPPER Function Operates on High-ASCII Characters (297133)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 3.0b
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 6.0

This article was previously published under Q297133

SYMPTOMS

When you use the UPPER function on strings that include high-ASCII characters, you may see unexpected changes.

CAUSE

Visual FoxPro makes characters uppercase that are considered alphabetic by the ISALPHA function. ISALPHA is not font-dependent, so fonts that include symbol characters appear to behave incorrectly when strings that are displayed in them are run through the UPPER function.

RESOLUTION

If you must use symbol characters in your uppercase strings, test each character and make it uppercase individually.
lcOldFontName = _SCREEN.FontName
lnOldFontSize = _SCREEN.FontSize
_SCREEN.FontName = "FoxFont"
_SCREEN.FontSize = 9

*!* 241 is the plus/minus character.
lcMixedString = "Value is 500" + CHR(241) + "0.05%"
? lcMixedString
? UPPER(lcMixedString)  && Displays box character

lcUpperString = ""
FOR i = 1 TO LEN(lcMixedString)
   lcCurrChar = SUBSTR(lcMixedString, i, 1)
   IF BETWEEN(lcCurrChar, "a", "z")
      lcCurrChar = UPPER(lcCurrChar)
   ENDif
   
   lcUpperString = lcUpperString + lcCurrChar
ENDfor

? lcUpperString

_SCREEN.FontName = lcOldFontName
_SCREEN.FontSize = lnOldFontSize
				

STATUS

This behavior is by design.

MORE INFORMATION

To see all characters that are affected by UPPER, run the following code:
_SCREEN.FontName = "Lucida Sans Unicode"
CLEAR

FOR i = 1 TO 255
   IF CHR(i) != UPPER(CHR(i))
      ? i, CHR(i), UPPER(CHR(i))
   ENDif
ENDfor
				
NOTE: Change the FontName property to "FoxFont" to see the problem that is described in the "Symptoms" section.

REFERENCES


Modification Type:MajorLast Reviewed:5/12/2003
Keywords:kbBug kbprb kbvfp500fix kbXBase KB297133