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 🙂
In ASCII, the character ‘A’ has value 65, so Letters[0] effectively contains an offset into the alphabet (A being 0).
If MGRS[j] is ‘I’ (73) then we take ‘A’ (65) from it to leave 8
The code is pretty much the same as: