Dear list,
A mata question: Why is "a" converted to uppercase == "A" (and also <= "A")
but NOT >= "A"?
. mata: strupper("a") >= "A"
0
. mata: strupper("a") == "A"
1
I was trying to determine if a string scalar was a letter and the obvious
scalar function isLetter(string scalar s) {
S = strupper(s)
return (S >= "A" & S <= "Z")
}
didn't work with "a" (although it works with "b" because strupper("b") >=
"A" is true). I got around the problem using the slightly more cryptic
scalar function isLetter(string scalar s) {
n = ascii(strupper(s))
return (n >= 65 & n <= 90)
}
but I am curious.
Cheers,
German
P.S. My Stata *is* up-to-date. I am running 9.1 born 20 Jan 2006
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/