예제 #1
0
  size_t CodePage2UnicodeConverter::convertToUnicode(UChar * pclTarget,
      size_t uiTargetMaxLength,
      const char * cpacSource,
      size_t uiSourceLength)
  /* ----------------------------------------------------------------------- */
  {
    size_t                     uiTargetSize;

    assert(iv_uconverter !=NULL);
    UErrorCode err=(UErrorCode)0;
    uiTargetSize = ucnv_toUChars(iv_uconverter, pclTarget, uiTargetMaxLength, cpacSource, uiSourceLength, &err);

    if (!U_SUCCESS(err) &&  err != U_BUFFER_OVERFLOW_ERROR) {
      cout << "ERROR: convertToUnicode " << err << endl;
      ///cerr << "CodePage2UnicodeConverter::getMaximumLength() rc= " << err << endl;
      ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_CODEPAGE_CONV_ERROR);
      errMsg.addParam(err);
      UIMA_EXC_THROW_NEW(CodePageConversionException,
                         UIMA_ERR_CODEPAGE,
                         errMsg,
                         UIMA_MSG_ID_CODEPAGE_CONV_ERROR,
                         ErrorInfo::unrecoverable);
    }
    return uiTargetSize;
    //// return(uiTargetSize / sizeof(UChar));       /* as characters */
  }
예제 #2
0
 CodePage2UnicodeConverter::CodePage2UnicodeConverter( const char * crConverterName) :
     iv_uconverter(NULL)
     /* ----------------------------------------------------------------------- */
 {
   UErrorCode err=(UErrorCode)0;
   iv_uconverter = ucnv_open(crConverterName, &err);
   if (!U_SUCCESS(err)) {
     cerr << "CodePage2UnicodeConverter ERROR could not open converter for " << crConverterName << endl;
     ErrorMessage errMsg = ErrorMessage(UIMA_MSG_ID_CODEPAGE_CONV_ERROR);
     errMsg.addParam(err);
     errMsg.addParam(crConverterName);
     UIMA_EXC_THROW_NEW(CodePageConversionException,
                        UIMA_ERR_CODEPAGE,
                        errMsg,
                        UIMA_MSG_ID_CODEPAGE_CONV_ERROR,
                        ErrorInfo::unrecoverable);
   }
   assert(iv_uconverter != NULL);
 }