/[svn]/qsampler/trunk/src/qsamplerUtilities.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerUtilities.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1513 by capela, Fri Nov 23 09:32:06 2007 UTC revision 1667 by schoenebeck, Mon Feb 4 23:24:19 2008 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, Christian Schoenebeck     Copyright (C) 2007, 2008 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 153  QString lscpEscapedPathToPosix(QString p Line 153  QString lscpEscapedPathToPosix(QString p
153      return path;      return path;
154  }  }
155    
156    // converts the given text as expected by LSCP 1.2
157    // (that is by encoding special characters with LSCP escape sequences)
158    QString lscpEscapeText(const QString& txt) {
159        if (!_remoteSupportsEscapeSequences()) return txt;
160    
161        QString text(txt);
162    
163        // replace all non-basic characters by LSCP escape sequences
164        for (int i = 0; i < int(text.length()); ++i) {
165            // match all non-alphanumerics
166            // (we could exclude much more characters here, but that way
167            // we're sure it just works^TM)
168            const char c = text.at(i).toLatin1();
169            if (
170                !(c >= '0' && c <= '9') &&
171                !(c >= 'a' && c <= 'z') &&
172                !(c >= 'A' && c <= 'Z')
173            ) {
174                // convert the non-basic character into a LSCP escape sequence
175                char buf[5];
176                ::snprintf(buf, sizeof(buf), "\\x%02x", static_cast<unsigned char>(c));
177                text.replace(i, 1, buf);
178                i += 3;
179            }
180        }
181    
182        return text;
183    }
184    
185  // converts a text returned by a LSCP command and may contain escape  // converts a text returned by a LSCP command and may contain escape
186  // sequences) into raw text, that is with all escape sequences decoded  // sequences) into raw text, that is with all escape sequences decoded
187  QString lscpEscapedTextToRaw(QString txt) {  QString lscpEscapedTextToRaw(QString txt) {

Legend:
Removed from v.1513  
changed lines
  Added in v.1667

  ViewVC Help
Powered by ViewVC