#if defined(_MSC_VER) typedef unsigned __int64 UINT64; #else typedef unsigned long long UINT64; #endif /* ---------------------------------------------------------- Encodes/Decodes case-insensitive identfier (maximum length 12 characters) to UINT64 dword ---------------------------------------------------------- syntax: identifier = symbol | identifier [symbol | digit] symbol = 'A'..'Z' | 'a'..'z'; digit = '0'..'9'; With simple words: identifier can't start with DIGITS... :)) Examples: "drumBaseSet0" "silentScope133" "silentScope443" "mainFrame0" "mainFrame1" Illegal examples: "drumBaseSet12" -> more than 12 characters!! (last one will be ignored) Also for each identifier you can have integer subId (0, 1 or 2) like: "playerID" : 1 "goalieID" : 2 "passerID" : 0 ---------------------------------------------------------------------- malkia@mindless.com http://easternAnalog.hypermart.net/ */ UINT64 EncodeId( char *buf, int subId ) { UINT64 code; int digit, i, ch; if( (unsigned)subId >= 3 ) return 0; ch = *buf++; if( ch >= 'A' && ch <= 'Z' ) code = ch - 'A' + 1; else if( ch >= 'a' && ch <= 'z' ) code = ch - 'a' + 1; else return 0; for( i=0; i<11; i++ ) { if( ch ) ch = *buf++; if( ch == 0 ) digit = ch; else if( ch >= 'A' && ch <= 'Z' ) digit = ch - 'A' + 1; else if( ch >= 'a' && ch <= 'z' ) digit = ch - 'a' + 1; else if( ch >= '0' && ch <= '9' ) digit = ch - '0' + 1 + 26; else return 0; code = code*37 + digit; } code = code*3 + subId; return code; } int DecodeId( UINT64 code, char buf[13] ) { int i, ch, subId; subId = (int)(code%3); code /= 3; i = 12; buf[12] = 0; while( i ) { ch = (int)(code%37); code /= 37; buf[--i] = (char)(ch?(ch - 1 + (ch<26?'A':'0')):0); } return subId; }