Logo Search packages:      
Sourcecode: capisuite version File versions  Download package

void Connection::convertToCP437 ( string &  text  )  [protected]

convert a String from ISO8859-1 to CP437 (IBM PC-DOS charset)

Unfortunately, some CAPI drivers expect the fax headline to be given in the IBM PC-DOS charset. This method can convert the string from the normal ISO8859-1 representation to this charset.

Parameters:
text the string to convert
Exceptions:
CapiExternalError thrown when the iconv* functions report an error (other than conversion not supported)

Definition at line 1099 of file connection.cpp.

References error, and prefix().

Referenced by buildBconfiguration().

{
      size_t from_length=text.size()+1;
      size_t to_length=from_length;

      char* from_buf=new char[from_length];
      char* from_buf_tmp=from_buf; // as pointer is changed by iconv()
      char* to_buf = new char[to_length];
      char* to_buf_tmp=to_buf; // as pointer is changed by iconv()

      strncpy(from_buf,text.c_str(),from_length);

      iconv_t conv=iconv_open("CP437","Latin1");

      if (conv==(iconv_t)-1) {
            error << prefix() << "WARNING: string conversion to CP437 not supported by iconv" << endl;
            return;
      }

      if (iconv(conv,&from_buf_tmp,&from_length,&to_buf_tmp,&to_length)==(size_t)-1) {
            char msg[200];
            error << prefix() << "WARNING: error during string conversion (iconv): " << strerror_r(errno,msg,200) << endl;
            return;
      }

      if (iconv_close(conv)!=0)
            throw CapiExternalError("error during string conversion (iconv_close)","Connection::convertToCP437");

      text=to_buf;
        delete[] from_buf;
        delete[] to_buf;
}


Generated by  Doxygen 1.6.0   Back to index