Example #1
0
// Function for fetching the time
QString MiningPage::getTime(QString time)
{
    if (time.contains("["))
    {
        time.resize(21);
        time.remove("[");
        time.remove("]");
        time.remove(0,11);

        return time;
    }
    else
        return NULL;
}
void Widget::resizeFunction()
{
//! [45]
    QString s = "Hello world";
    s.resize(5);
    // s == "Hello"

    s.resize(8);
    // s == "Hello???" (where ? stands for any character)
//! [45]

//! [46]
    QString t = "Hello";
    t += QString(10, 'X');
    // t == "HelloXXXXXXXXXX"
//! [46]

//! [47]
    QString r = "Hello";
    r = r.leftJustified(10, ' ');
    // r == "Hello     "
//! [47]
}
Example #3
0
void ExportWizard::browseButtonClicked() {
  QString filter;
  QString all = "all supported formats (";
  const std::list<std::string> modules = PluginLister::instance()->availablePlugins<ExportModule>();

  for (std::list<std::string>::const_iterator itm = modules.begin(); itm != modules.end(); ++itm) {
    ExportModule *p = PluginLister::instance()->getPluginObject<ExportModule>(*itm, nullptr);
    const std::list<std::string> extension = p->allFileExtensions();
    filter += tlpStringToQString(p->name()) + " (";

    for (list<string>::const_iterator it = extension.begin(); it != extension.end(); ++it) {
      filter += (*it).c_str() + QString(" ");
      all += (*it).c_str() + QString(" ");
    }

    filter.resize(filter.length() - 1);
    filter += ");;";
    delete p;
  }

  filter.resize(filter.length() - 2);
  all.resize(all.length() - 1);
  all = all + ");;" + filter;
  QString exportFile =
      QFileDialog::getSaveFileName(this, "Export file", _ui->pathEdit->text(), all, nullptr
// on MacOSX selectedFilter is ignored by the
// native dialog
#ifdef __APPLE__
                                   ,
                                   QFileDialog::DontUseNativeDialog
#endif
      );

  if (!exportFile.isEmpty()) {
    _ui->pathEdit->setText(exportFile);
  }
}
QString Message::text( QTextCodec *codec ) const
{
	switch ( d->encoding )
	{
	case Message::UserDefined:
		return codec->toUnicode( d->textArray );
	case Message::ASCII:
		return QString::fromAscii( d->textArray.data(), d->textArray.size() );
	case Message::LATIN1:
		return QString::fromLatin1( d->textArray.data(), d->textArray.size() );
	case Message::UTF8:
		return QString::fromUtf8( d->textArray.data(), d->textArray.size() );
	case Message::UCS2:
	{
		uint len = d->textArray.size() / 2;
		QString result;
		result.resize( len );
		QByteArray::ConstIterator p = d->textArray.begin();
		for ( uint i = 0; i < len; i++)
		{
			char row = *p++;
			char cell = *p++;
			result[i] = QChar( cell, row );
		}
		//check if last character isn't null
		if ( result.at(len-1).isNull() )
			result.resize( len - 1 );

		return result;
	}
	default:
		break; // Should never happen.
	}
	return QString();
	//FIXME: warn at least with kdWarning if an unrecognised encoding style was seen.
}
void BiliSceneWidgetItem::limitLabelContext(QLabel* label, 
	                                        const QString &ori_context, 
											int context_len, 
											const QString &spacer)
{
	QString context = ori_context;

	if (ori_context.size() <= context_len + 1)
		label->setText(context);
	else {
		context.resize(context_len);
		label->setText(context + spacer);
	}
	
}
Example #6
0
void TabWidget::setTabNameAndTooltip(int idx, QString name)
{
    setTabToolTip(idx, name);

    if(idx == currentIndex())
        emit changeWindowTitle(name);

    if(name.size() > 25)
    {
        name.resize(28);
        name.replace(25, 3, "...");
    }

    setTabText(idx, name);
}
Example #7
0
void removeFile(LVPtrVector<CRFileHistRecord> & files, int num)
{
	// remove cache file
	QString filename = cr2qt(files.get(num-1)->getFileName());
	// trim file extension, need for archive files
	int pos = filename.lastIndexOf(".");
	if(pos != -1) filename.resize(pos);

	QDir Dir(qApp->applicationDirPath() + QDir::toNativeSeparators(QString("/data/cache/")));
	QStringList fileList = Dir.entryList(QStringList() << filename + "*.cr3", QDir::Files);
	if(fileList.count())
		Dir.remove(fileList.at(0));

	files.remove(num-1);
}
Example #8
0
QString ClassParser::findFullFilePathForHeaderInformation(ClassParserIncludeHeaderInformation *pIncludeHeader, const char *strHeaderFullFilePath) {

    unsigned int i;
    unsigned int iCount = strlen(strHeaderFullFilePath);
    unsigned int iLastSeparator = iCount;
    QString strFilePath;
    QString strNewFuleFilePath;

    for (i=0; i<iCount; i++) {

        if (strHeaderFullFilePath[i] == '/' || strHeaderFullFilePath[i] == '\\') {

            iLastSeparator = i;
        }
    }

    if (iLastSeparator != iCount) {

        strFilePath = strHeaderFullFilePath;
        strFilePath.resize(iLastSeparator+1);

        if (pIncludeHeader->m_bInPublicIncludeFolders) {

            for (int ii=0; ii<m_listPublicIncludePaths.size(); ii++) {

                strNewFuleFilePath = m_listPublicIncludePaths[ii] + "/" + pIncludeHeader->m_strIncludeHeader;
                QFile file(strNewFuleFilePath);
                if (file.exists()) {

                    return strNewFuleFilePath;
                }
            }

        }
        else {

            strFilePath += pIncludeHeader->m_strIncludeHeader;

            QFile file(strFilePath);
            if (file.exists()) {

                return strFilePath;
            }
        }
    }

    return "";
}
Example #9
0
QString ElfParser::GetOpersymRef( const QString &str )
{
	QString ret;
	int o = str.indexOf( '<' );
	if( o < 0 )
	{
		return QString();
	}
	ret = str.mid( o + 1 );
	if( !ret.endsWith( '>' ) )
	{
		return QString();
	}
	ret.resize( ret.size() - 1 );
	return ret;
}
Example #10
0
QT_BEGIN_NAMESPACE

static QString fromLatin1(const char *chars, int len)
{
	if (chars == 0)
        return QString();

	QString r;
	r.resize(len);

	ushort *i = r.data();
    while (len--)
       *i++ = (uchar)*chars++;

	return r;
}
Example #11
0
bool ExportWizard::validateCurrentPage() {
  QString exportFile = outputFile();

  // check correct extension
  ExportModule *p = PluginLister::instance()->getPluginObject<ExportModule>(
      tlp::QStringToTlpString(algorithm()), nullptr);
  std::list<std::string> extension;

  if (p != nullptr)
    extension = p->allFileExtensions();

  bool extok(false);
  QString ext;

  for (list<string>::const_iterator it = extension.begin(); it != extension.end(); ++it) {
    ext += tlp::tlpStringToQString(*it) + ", ";

    if (exportFile.endsWith(tlp::tlpStringToQString(*it))) {
      extok = true;
    }
  }

  delete p;

  if (!extok) {
    if (extension.size() == 1)
      _ui->pathEdit->setText(exportFile + "." + tlp::tlpStringToQString(*extension.begin()));
    else {
      ext.resize(ext.length() - 2);
      QString msg = "Filename does not terminate with a valid extension. ";

      if (!algorithm().isEmpty())
        msg += "Please add one.<br>Valid extensions for " + algorithm() + " are: " + ext;

      QMessageBox::warning(parentWidget(), "Filename not valid", msg);
      return false;
    }
  }

  // if file exists and is valid, check if user wants to overwrite it
  return (!exportFile.isEmpty() &&
          (!QFile::exists(exportFile) ||
           (QMessageBox::question(
                parentWidget(), "Overwriting an existing file",
                "The export file already exists.<br/>Do you really want to overwrite it?",
                QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)));
}
Example #12
0
/** Browses image file to open and sets the new path to image path line edit. */
void EffectsScrollArea::browseImage() {
    QString path = imagePathLineEdit->text();
    QFileInfo oldImageFileInfo(path);
    if (oldImageFileInfo.exists())
        path = oldImageFileInfo.absoluteDir().absolutePath();
    else
        path = QDir::homePath();
    QString formats;
    foreach (QByteArray format, QImageReader::supportedImageFormats())
        formats += "*." + format + ' ';
    formats.resize(formats.size()-1);

    path = QFileDialog::getOpenFileName(this, tr("Choose Image File"), path,
                                        tr("Images")+" ("+formats+")");
    if (!path.isEmpty())
        imagePathLineEdit->setText(path);
}
Example #13
0
QString Functions::cleanFileName( QString f )
{
	if ( f.length() > 200 )
		f.resize( 200 );
	f.replace( '/', '_' );
#ifdef Q_OS_WIN
	f.replace( '\\', '_' );
	f.replace( ':', '_' );
	f.replace( '*', '_' );
	f.replace( '?', '_' );
	f.replace( '"', '_' );
	f.replace( '<', '_' );
	f.replace( '>', '_' );
	f.replace( '|', '_' );
#endif
	return f;
}
Example #14
0
QString KRandom::randomString(int length)
{
   if (length <=0 ) return QString();

   QString str; str.resize( length );
   int i = 0;
   while (length--)
   {
      int r=random() % 62;
      r+=48;
      if (r>57) r+=7;
      if (r>90) r+=6;
      str[i++] =  char(r);
      // so what if I work backwards?
   }
   return str;
}
void RecentBooksDlg::removeFile(LVPtrVector<CRFileHistRecord> & files, int num)
{

    QDir Dir0( cr2qt(files[num-1]->getFilePath()) );
    // Удаляемый файл ещё существует
    if((Dir0.exists( cr2qt(files.get(num-1)->getFileName()) )) && (files.length() > 1)){
        // Нужно чтобы в истории было больше одной книжки, чтобы можно было загрузить удяляемую запись а потом удалить
        m_docview->loadDocument(cr2qt(files[num-1]->getFilePathName()));

        // remove cache file
        QString filename = cr2qt(files.get(num-1)->getFileName());
        filename = cr2qt(m_docview->getDocView()->getDocProps()->getStringDef(DOC_PROP_FILE_NAME));

        // Уточняем CRC удаляемого файла
        lUInt32 crc = m_docview->getDocView()->getDocProps()->getIntDef(DOC_PROP_FILE_CRC32, 0);
        char s[16];
        sprintf(s, ".%08x", (unsigned)crc);
        filename = filename+ QString(s);

        // Возвращаем активным первоначально просматриваемый документ (он сейчас первым в списке истории стоит)
        m_docview->loadDocument(cr2qt(files[1]->getFilePathName()));
        //	// для отладки

        // trim file extension, need for archive files

        QDir Dir(qApp->applicationDirPath() + QDir::toNativeSeparators(QString("/data/cache/")));
        QStringList fileList = Dir.entryList(QStringList() << filename + "*.cr3", QDir::Files);
        if(fileList.count())
            Dir.remove(fileList.at(0));

        files.remove(1);
    } else {
        // Известно лишь название архива и если его название не совпадает с названием файла то кеш файл не будет удалён
        // remove cache file
        QString filename = cr2qt(files.get(num-1)->getFileName());
        // trim file extension, need for archive files
        int pos = filename.lastIndexOf(".");
        if(pos != -1) filename.resize(pos);
        QDir Dir(qApp->applicationDirPath() + QDir::toNativeSeparators(QString("/data/cache/")));
        QStringList fileList = Dir.entryList(QStringList() << filename + "*.cr3", QDir::Files);
        if(fileList.count())
            Dir.remove(fileList.at(0));
        files.remove(num-1);
    }
}
Example #16
0
void CPlugin::callback(int p_callbackId, const QString &p_jsParameters) {
    QString javascript;
    if (p_jsParameters.length() > 0) {
        javascript = QString("cordova.callback(%1, %2);").arg(p_callbackId).arg(p_jsParameters);
    }
    else {
        javascript = QString("cordova.callback(%1);").arg(p_callbackId);
    }

    if (javascript.size() > 1000) {
        QString t = javascript;
        t.resize(1000);
        qDebug() << "Running: " << t;
    } else {
        qDebug() << "Running: " << javascript;
    }
    m_cordova->execJS(javascript);
}
Example #17
0
void MainWindow::on_action_topologicalSorting_triggered()
{
    QList<int> topologicalSorting = _scene->graph()->topologicalSorting();

    QString sorting;
    if(!topologicalSorting.isEmpty()) {
        sorting.reserve(topologicalSorting.size() * 4);
        for(int v : topologicalSorting) {
            sorting.append(QString::number(v));
            sorting.append(" - ");
        }
        sorting.resize(sorting.size() - 3);
    } else {
        sorting = tr("Топологічне сортування, для даного графу, неможливе");
    }

    _matrixViewWindow->showSimpleString(sorting, tr("Топологічне сортування"));
}
Example #18
0
/**
 * @brief cwCompassImporter::parseSurveyTeam
 * @param file
 */
void cwCompassImporter::parseSurveyTeam(QFile *file)
{
    if(!CurrentFileGood) { return; }
    QString surveyTeamLabel = file->readLine();
    surveyTeamLabel = surveyTeamLabel.trimmed();

    LineCount++;
    if(!isFileGood(file, "survey team")) { return; }

    if(surveyTeamLabel.compare("SURVEY TEAM:") != 0) {
        emit statusMessage(QString("I was expecting to find \"SURVEY TEAM:\" but instead found \"%1\", in %2 on line %3")
                           .arg(surveyTeamLabel)
                           .arg(CurrentFilename)
                           .arg(LineCount));
    }

    QString surveyTeam = file->readLine();
    surveyTeam = surveyTeam.trimmed();

    LineCount++;
    if(!isFileGood(file, "survey team")) { return; }

    if(surveyTeam.size() > 100) {
        emit statusMessage(QString("I found the team to be longer than 100 characters. I'm trimming it to 100 characters, in %1 on line %2")
                           .arg(CurrentFilename)
                           .arg(LineCount));
        surveyTeam.resize(100);
    }

    QRegExp delimiter;
    if (surveyTeam.contains(';')) {
        delimiter = QRegExp("\\s*;\\s*");
    } else {
        delimiter = QRegExp("\\s\\s+|\\s*,\\s*");
    }

    QStringList teamList = surveyTeam.split(delimiter, QString::SkipEmptyParts);
    if(!teamList.isEmpty()) {
        cwTeam* team = new cwTeam();

        foreach(QString name, teamList) {
            cwTeamMember member(name, QStringList());
            team->addTeamMember(member);
        }
Example #19
0
QString AFormatter::nick3 (const QString& nick)
{
	if (nick.length() < 4)
		return nick;

	QString result;

	for (int i = 0; i < nick.length(); i++)
		if (nick[i].isUpper() == true)
			result += nick[i];

	if (result.length() == 0)
		result = nick[0];

	if (result.length() > 3)
		result.resize(3);

	return result;
}
Example #20
0
static void unicodeToEncodedUtf8(QString &result, ushort *&output, const ushort *begin,
                                 const ushort *&input, const ushort *end, ushort decoded)
{
    uint uc = decoded;
    if (QChar::isHighSurrogate(uc)) {
        if (input < end && QChar::isLowSurrogate(input[1]))
            uc = QChar::surrogateToUcs4(uc, input[1]);
    }

    // note: we will encode bad UTF-16 to UTF-8
    // but they don't get decoded back

    // calculate the utf8 length
    int utf8len = uc >= 0x10000 ? 4 : uc >= 0x800 ? 3 : 2;

    // detach
    if (!output) {
        // we need 3 * utf8len for the encoded UTF-8 sequence
        // but ensureDetached already adds 3 for the char we're processing
        ensureDetached(result, output, begin, input, end, 3*utf8len - 3);
    } else {
        // verify that there's enough space or expand
        int charsRemaining = end - input - 1; // not including this one
        int pos = output - reinterpret_cast<const ushort *>(result.constData());
        int spaceRemaining = result.size() - pos;
        if (spaceRemaining < 3*charsRemaining + 3*utf8len) {
            // must resize
            result.resize(result.size() + 3*utf8len);

            // we know that resize() above detached, so we bypass the reference count check
            output = const_cast<ushort *>(reinterpret_cast<const ushort *>(result.constData()));
            output += pos;
        }
    }

    // write the sequence
    if (uc < 0x800) {
        // first of two bytes
        uchar c = 0xc0 | uchar(uc >> 6);
        *output++ = '%';
        *output++ = encodeNibble(c >> 4);
        *output++ = encodeNibble(c & 0xf);
    } else {
Example #21
0
// removes surrounding quotes, removes trailing slashes, converts to native separators.
// accepts unescaped but possible quoted path
QString qc_normalize_path(const QString &str)
{
	QString path = str.trimmed();
	path = qc_trim_char(path, QLatin1Char('"'));
	path = qc_trim_char(path, QLatin1Char('\''));

	// It's OK to use unix style'/' pathes on windows Qt handles this without any problems.
	// Using Windows-style '\\' can leads strange compilation error with MSYS which uses
	// unix style.
	QLatin1Char nativeSep('/');
#ifdef Q_OS_WIN
	path.replace(QLatin1Char('\\'), QLatin1Char('/'));
#endif
	// trim trailing slashes
	while (path.length() && path[path.length() - 1] == nativeSep) {
		path.resize(path.length() - 1);
	}
	return path;
}
Example #22
0
QT_BEGIN_NAMESPACE

static void replaceMultipleNewlines(QString &s)
{
    const int n = s.size();
    bool slurping = false;
    int j = -1;
    const QChar newLine = QLatin1Char('\n');
    QChar *d = s.data();
    for (int i = 0; i != n; ++i) {
        const QChar c = d[i];
        bool hit = (c == newLine);
        if (slurping && hit)
            continue;
        d[++j] = c;
        slurping = hit;
    }
    s.resize(++j);
}
void QblDesktopChatContent::keyReleaseEvent(QKeyEvent *event)
{
    if (this->ui->teMessage->hasFocus()) {
        if (event->key() == Qt::Key_Return) {
            if (! (event->modifiers() & Qt::ShiftModifier)
                    && ! (event->modifiers() & Qt::ControlModifier)) {
                QString msg;

                msg = this->ui->teMessage->toPlainText();
                msg.resize(msg.length() - 1);
                this->ui->teMessage->setPlainText(msg);

                this->on_btSend_clicked();
            }
        }
    }

    return;
}
Example #24
0
PatternCompiler::MatchRepr PatternCompiler::convertMatch(lspl::text::MatchRef ref,PatternType patternType)
{
    QString text = convertToSystem(ref->getRangeString());
    QString transform;
    QString params;
    uint vars = ref->getVariantCount();
    lspl::text::Match::AttributesMap attrMap = ref->getAttributes();
    for(std::map<lspl::text::attributes::AttributeKey,lspl::text::attributes::AttributeValue>::iterator itr = attrMap.begin();
        itr != attrMap.end();++itr)
    {
        QString title = convertToSystem(itr->first.getTitle());
        QString value = convertToSystem(itr->second.getTitle());
        QString otherValue;
        if(value == "неопределено"){
            otherValue = convertToSystem(itr->second.getString());
        }
        if(otherValue != ""){
            value = otherValue;
        }
        if(!title.isEmpty() && ! value.isEmpty()){
            params += title+" : " + value + ", ";
        }
    }
    params.resize(params.length()-2);
    switch(patternType){
    case RIGHT_PART_PATTERN:
    {
        lspl::patterns::PatternRef p = ref->getVariant(0)->getTransformResult<lspl::patterns::PatternRef>();
        transform = convertToSystem(p->getName().c_str()) + " = " + convertToSystem(p->getSource().c_str());
        break;
    }
    case RIGHT_PART_TEXT:
    {
        transform = convertToSystem(ref->getVariant(0)->getTransformResult<std::string>().c_str());
        break;
    }
    default:
        transform = "";
        break;
    }
    return {text, params, transform, ref->getRangeStart(),ref->getRangeEnd(),vars};
}
Example #25
0
bool PSPApplication::isPercentMultiple(QDir dir)
{
    //Get the dir name of the pbp container
    QString dirName = dir.dirName();//dir.absolutePath();
    
    //Set the name of the other dir
    QString otherName = dirName;
    if (dirName.endsWith("%"))
    {
        otherName.resize(otherName.length() -  1);
    }
    else
    {
        otherName.append("%");
    }
    
    
    //Now we have to check that both the otherName dir exists
    //and it has a valid PBP file
	dir.cdUp();
    QDir otherDir(dir.absolutePath() +"/"+ otherName);
    if (!otherDir.exists())
    {
        return false;
    }
    
    //Find the eboot.pbp file inside the dir
    QFileInfoList files;
    files = otherDir.entryInfoList(QDir::Files | QDir::NoSymLinks);
    for (int i = 0; i < files.size(); ++i) 
    {
        if (files.at(i).fileName().toLower() == "eboot.pbp")
        {
            if (isPBPSignature(files.at(i).filePath()))
            {
                return true; //We have the correct directory and contains a correct pbp file
            }
        }
    }
    
    return false;
}
void WeatherWidget::setCity(QString city)
{
    // set city from string passed form setting screen
    // format city string correctly to display properly
    QStringList cityList = city.split(",");
    QString cityShort = cityList.at(0);
    if(cityShort.size() > 9) {
        cityShort.resize(9);
    }
    QString countryShort;

    if(cityList.at(1).size() < 3) {
        countryShort = cityList.at(1);
    } else if (cityList.at(1) == "Japan") {
        countryShort.append("JP");
    } else if (cityList.at(1) == "South Korea") {
        countryShort.append("KR");
    } else if (cityList.at(1) == "Mexico") {
        countryShort.append("MX");
    } else if (cityList.at(1) == "India") {
        countryShort.append("IN");
    } else if (cityList.at(1) == "Indonesia") {
        countryShort.append("ID");
    } else if (cityList.at(1) == "Brazil") {
        countryShort.append("BR");
    } else if (cityList.at(1) == "China") {
        countryShort.append("CN");
    } else if (cityList.at(1) == "Germany") {
        countryShort.append("DE");
    }else if (cityList.at(1) == "Russia") {
        countryShort.append("RU");
    } else if (cityList.at(1) == "Egypt") {
        countryShort.append("EG");
    } else if (cityList.at(1) == "South Africa") {
        countryShort.append("ZA");
    } else if (cityList.at(1) == "Taiwan") {
        countryShort.append("TW");
    }



}
Example #27
0
/**
 * @brief cwCompassImporter::parseCaveName
 * @param file
 */
void cwCompassImporter::parseCaveName(QFile *file)
{
    if(!CurrentFileGood) { return; }
    QString caveName = file->readLine();

    caveName = caveName.trimmed();

    LineCount++;

    if(caveName.size() > 80) {
        emit statusMessage(QString("I found the cave name to be longer than 80 characters. I'm trimming it to 80 characters, in %1 on line %2")
                           .arg(CurrentFilename)
                           .arg(LineCount));
        caveName.resize(80);
    }


    if(!isFileGood(file, "cave name")) { return; }
    CurrentCave->setName(caveName);
}
void customQListWidget::RenameFolder()
{
    bool ok;
    QString newFolderName = QInputDialog::getText(this,tr("Renombrando..."),tr("Nuevo nombre de la carpeta: "),QLineEdit::Normal,
                                               "", &ok);

    if(ok && !newFolderName.isEmpty())
    {
        pfsFolder *f = (pfsFolder *)this->currentItem();
        dir_info_t *temp = f->getDirEntry();

        newFolderName.resize(sizeof(temp->dirEntry->name));

        DiskFunctions::getInstace()->renameFolder((char*)newFolderName.toStdString().c_str(), temp);

        //ACTUALIZAR LA INFO DEL ITEM
        this->currentItem()->setText(QString::fromAscii((char*)temp->dirEntry->name, sizeof(temp->dirEntry->name)));
        ((pfsFolder*)this->currentItem())->setDirEntry(temp);
    }
}
Example #29
0
void KsirkChatModel::addMessage(const KsirkChatItem& message)
{
  QString msg;
  if ((QString(message.first)).length() == 0) {
     msg = i18n("No message...");
  } else {
    msg = i18n("<b>%1:</b> %2", message.first, message.second);
     if (msg.length() > 77) {
        msg.resize(64);
        msg += " ...";
     }
  }
  m_game->titleChatMessage()->setText(msg);

  int row;
  row = m_messages.size();
  beginInsertRows(QModelIndex(), row, row);
  m_messages.push_back(message);
  endInsertRows();
}
Example #30
0
QString TAlgorithm::randomString(int length)
{
    if (length <=0) 
        return QString();

    QString str; str.resize(length);

    int i = 0;
    while (length--) {
           int r=random() % 62;
           r+=48;
           if (r>57) 
               r+=7;
           if (r>90) 
               r+=6;
           str[i++] =  char(r);
    }

    return str;
}