00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00035 #include "OW_String.hpp"
00036 #include "OW_Array.hpp"
00037 #include "OW_StringStream.hpp"
00038 #include "OW_UTF8Utils.hpp"
00039 #include <fstream>
00040 #include <iostream>
00041 #include <assert.h>
00042 
00043 using namespace std;
00044 using namespace OpenWBEM;
00045 
00046 StringArray sa1;
00047 StringArray sa2;
00048 
00049 void printStrings(const String& str1, const String& str2)
00050 {
00051    cout << "\tunitAssert(UTF8Utils::compareToIgnoreCase(\"";
00052    for (int i = 0; i < str1.length(); ++i)
00053    {
00054       cout << hex << "\\x" << (int)(unsigned char)str1[i];
00055    }
00056    cout << "\", \"";
00057    for (int i = 0; i < str2.length(); ++i)
00058    {
00059       cout << hex << "\\x" << (int)(unsigned char)str2[i];
00060    }
00061    cout << "\") == 0)\n";
00062 }
00063 
00064 
00065 
00066 struct processLine
00067 {
00068    void operator()(const String& s) const
00069    {
00070       if (s.empty() || !isxdigit(s[0]))
00071          return;
00072 
00073       StringArray a = s.tokenize(";"); 
00074       assert(a.size() >= 3);
00075       UInt32 c1 = a[0].toUInt32(16);
00076       StringArray a2 = a[2].tokenize(" "); 
00077       Array<UInt32> c2chars(a2.size());
00078       for (size_t i = 0; i < a2.size(); ++i)
00079       {
00080          c2chars[i] = a2[i].toUInt32(16);
00081       }
00082       String str1 = UTF8Utils::UCS4toUTF8(c1);
00083       String str2;
00084       for (size_t i = 0; i < c2chars.size(); ++i)
00085       {
00086          str2 += UTF8Utils::UCS4toUTF8(c2chars[i]);
00087       }
00088 
00089       sa1.push_back(str1);
00090       sa2.push_back(str2);
00091       sa1.push_back(str2);
00092       sa2.push_back(str1);
00093    }
00094 };
00095 
00096 int main(int argc, char** argv)
00097 {
00098    if (argc != 2)
00099    {
00100       cerr << "must pass filename (to CaseFolding.txt)" << endl;
00101       return 1;
00102    }
00103 
00104    ifstream in(argv[1]);
00105    if (!in)
00106    {
00107       cerr << "could not open " << argv[1] << endl;
00108       return 1;
00109    }
00110 
00111    
00112    for (int i = 1; i < 256; ++i)
00113    {
00114       String s = String(char(i));
00115       sa1.push_back(s);
00116       sa2.push_back(s);
00117    }
00118 
00119    
00120    OStringStream ss;
00121    ss << in.rdbuf();
00122    String s = ss.toString();
00123    StringArray sa = s.tokenize("\n");
00124    for_each(sa.begin(), sa.end(), processLine());
00125    
00126    for (int i = 0; i < sa1.size(); ++i)
00127    {
00128       printStrings(sa1[i], sa2[i]);
00129    }
00130    
00131    for (int i = 0; i < sa1.size();)
00132    {
00133       String s1, s2;
00134       for (int j = 0; j < 10 && i < sa1.size(); ++j, ++i)
00135       {
00136          s1 += sa1[i];
00137          s2 += sa2[i];
00138       }
00139       printStrings(s1, s2);
00140    }
00141 }
00142