41 #include <tqcstring.h>
42 #include <mimelib/string.h>
46 if ( !str || strLen == 0 )
49 const char* source = str;
50 const char* sourceEnd = source + strLen;
53 for ( ; source < sourceEnd - 1; ++source ) {
54 if ( *source ==
'\r' && *( source + 1 ) ==
'\n' )
58 if ( source == sourceEnd - 1 ) {
64 char* target =
const_cast<char*
>( source );
66 for ( ; source < sourceEnd; ++source ) {
67 if ( *source !=
'\r' || *( source + 1 ) !=
'\n' )
76 TQCString result( 1 + 2*src.size() );
78 TQCString::ConstIterator s = src.begin();
79 TQCString::Iterator d = result.begin();
83 if ( (
'\n' == *s) && (
'\r' != cPrev) )
88 result.truncate( d - result.begin() );
94 const char* s = src.data();
98 TQByteArray result( 2 * src.size() );
99 TQByteArray::Iterator d = result.begin();
102 const char* end = src.end();
104 if ( (
'\n' == *s) && (
'\r' != cPrev) )
109 result.truncate( d - result.begin() );
115 const int strLen = str.size();
116 TQCString cstr( strLen + 1 );
117 memcpy( cstr.data(), str.data(), strLen );
124 const int strLen = str.size();
125 TQByteArray arr( strLen );
126 memcpy( arr.data(), str.data(), strLen );
134 return DwString( str.data(), str.size() - 1 );
141 return DwString( str.data(), str.size() );
147 uint len1 = that.size();
148 uint len2 = str.size();
149 if ( that.resize( len1 + len2, TQGArray::SpeedOptim ) )
150 memcpy( that.data() + len1, str.data(), len2 );
158 uint len1 = that.size();
159 uint len2 = tqstrlen(str);
160 if ( that.resize( len1 + len2, TQGArray::SpeedOptim ) )
161 memcpy( that.data() + len1, str, len2 );
167 uint len1 = that.size();
168 uint len2 = str.size() - 1;
169 if ( that.resize( len1 + len2, TQGArray::SpeedOptim ) )
170 memcpy( that.data() + len1, str.data(), len2 );
174 void KMail::Util::insert( TQByteArray& that, uint index,
const char* s )
176 int len = tqstrlen(s);
179 uint olen = that.size();
180 int nlen = olen + len;
181 if ( index >= olen ) {
183 if ( that.resize(nlen+index-olen, TQGArray::SpeedOptim ) ) {
184 memset( that.data()+olen,
' ', index-olen );
185 memcpy( that.data()+index, s, len );
189 if ( that.resize(nlen, TQGArray::SpeedOptim ) ) {
190 memmove( that.data()+index+len, that.data()+index, olen-index );
191 memcpy( that.data()+index, s, len );
void append(TQByteArray &that, const TQByteArray &str)
Append a bytearray to a bytearray.
TQByteArray ByteArray(const DwString &str)
Construct a TQByteArray from a DwString.
TQCString lf2crlf(const TQCString &src)
Convert "\n" line endings to "\r\n".
TQCString CString(const DwString &str)
Construct a TQCString from a DwString.
DwString dwString(const TQCString &str)
Construct a DwString from a TQCString.
size_t crlf2lf(char *str, const size_t strLen)
Convert all sequences of "\r\n" (carriage return followed by a line feed) to a single "\n" (line feed...