/****************************************************************************** * * translittest.cpp - * * $Id: translittest.cpp 2833 2013-06-29 06:40:28Z chrislit $ * * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society * P. O. Box 2528 * Tempe, AZ 85280-2528 * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation version 2. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * */ #include #include #include "unicode/udata.h" /* Data structures */ #include "unicode/ures.h" /* Data structures */ #include "unicode/utypes.h" /* Basic ICU data types */ #include "unicode/ucnv.h" /* C Converter API */ #include "unicode/ustring.h" /* some more string fcns*/ #include "unicode/translit.h" #include "utf8transliterator.h" using namespace std; // Print the given string to stdout void uprintf(const UnicodeString &str) { char *buf = 0; int32_t len = str.length(); // int32_t bufLen = str.extract(0, len, buf); // Preflight /* Preflighting seems to be broken now, so assume 1-1 conversion, plus some slop. */ int32_t bufLen = len + 16; int32_t actualLen; buf = new char[bufLen + 1]; actualLen = str.extract(0, len, buf/*, bufLen*/); // Default codepage conversion buf[actualLen] = 0; //printf("%s", buf); std::cout << buf; delete buf; } int main() { UErrorCode status = U_ZERO_ERROR; // UDataMemory *pappData = udata_open("/usr/local/lib/sword/swicu", "res", "root", &status); if (U_FAILURE(status)) { std::cout << "error: " << status << ":" << u_errorName(status) << std::endl; return 0; } UChar * uBuf; UChar * target; UConverter *conv; //UParseError perr = U_ZERO_ERROR; int32_t uBufSize = 0, uLength = 0; // void * pAppData=NULL; const char * samplestring = "If this compiles and runs without errors, apparently ICU is working."; //ures_open("/usr/local/lib/sword/swicu.dat", // NULL, &status); //UDataMemory *pappData = udata_open("/usr/local/lib/sword/swicu", // "res", "root", &status); if (U_FAILURE(status)) { std::cout << "error: " << status << ":" << u_errorName(status) << std::endl; return 0; } //UDataMemory *pappData2 = udata_open("/usr/local/lib/sword/swicu", // "res", "translit_Latin_Gothic", &status); std::cout << status << std::endl; if (U_FAILURE(status)) { std::cout << "error: " << status << ":" << u_errorName(status) << std::endl; return 0; } std::cout << "available " << Transliterator::countAvailableIDs() << std::endl; //udata_setAppData("/usr/local/lib/sword/swicu.dat" , pAppData, &status); //if (U_FAILURE(status)) //{ //std::cout << "error: " << status << ":" << // u_errorName(status) << std::endl; //return 0; //} int32_t i_ids = Transliterator::countAvailableIDs(); std::cout << "available " << i_ids << std::endl; for (int i=0; i