Changeset 1073


Ignore:
Timestamp:
May 28, 2011 9:00:53 PM (9 years ago)
Author:
dubbs
Message:

Only uppercase ascii letters to be able to handle unicode characters
and not break existing licenses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils/us_license_t.cpp

    r14 r1073  
    122122  int sum2 = 0;
    123123
    124   QString STR1 = str1.toUpper();
    125   QString STR2 = str2.toUpper();
     124  const static QString lower = "abcdefghijklmnopqrstuvwxyz";
     125  const static QString upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
     126
     127  //QString STR1 = str1.toUpper();
     128  //QString STR2 = str2.toUpper();
     129  QString STR1 = str1;
     130  QString STR2 = str2;
    126131
    127132  for ( int i = 0; i < STR1.length(); i++ )
    128133  {
    129     QChar c  = STR1.at( i );
    130     sum1    += c.unicode();
     134    QChar c = STR1.at( i );
     135
     136    // Make upper case for ascii only
     137    int   index = lower.indexOf( c );
     138    if ( index >= 0 )
     139       c = upper.at( index );
     140
     141    sum1 += c.unicode();
    131142  }
    132143
    133144  for ( int i = 0; i < STR2.length(); i++ )
    134145  {
    135     QChar c  = STR2.at( i );
    136     sum2    += c.unicode();
     146    QChar c = STR2.at( i );
     147
     148    // Make upper case for ascii only
     149    int   index = lower.indexOf( c );
     150    if ( index >= 0 )
     151       c = upper.at( index );
     152
     153    sum2 += c.unicode();
    137154  }
    138155
     
    142159
    143160  QString code;
     161  code = code.sprintf( "000%X", x ).right( 4 );
    144162
    145   return code.sprintf( "000%X", x ).right( 4 );
     163  return code;
    146164}
Note: See TracChangeset for help on using the changeset viewer.