I'm migrating a script from C to PHP (http://svn.stellman-greene.com/mgrs_to_utm/trunk/) and I have a problem with this concept in mgrs_to_utm.c:
Letters[0] = (toupper(MGRS[j]) - (long)'A');
if ((Letters[0] == LETTER_I) || (Letters[0] == LETTER_O))
MGRS[j] is a part of string, but WTF I can substract a (long)'A' to a LETTER??
LETTER_I is an integer (defined in mgrs_to_utm.h).
I have in mind PHP and I can't found the logic to this operation.
Thanks a lot for your help :)
LONGbut this is actually very common to convert a letter from ASCII to the number of the letter in the alphabet. Characters are just normal integers, so having achar cit's okay to dotoupper(c) - 'A'.ord(strtoupper(MGRS[j])) - ord('A')I think, this php is equivalent to thatccode. But note from manual, it won't always return US-ASCII value.