Пример #1
0
void AttachedPictureFrameV22::parseFields(const ByteVector &data)
{
  if(data.size() < 5) {
    debug("A picture frame must contain at least 5 bytes.");
    return;
  }

  d->textEncoding = String::Type(data[0]);

  int pos = 1;

  String fixedString = String(data.mid(pos, 3), String::Latin1);
  pos += 3;
  // convert fixed string image type to mime string
  if (fixedString.upper() == "JPG") {
    d->mimeType = "image/jpeg";
  } else if (fixedString.upper() == "PNG") {
    d->mimeType = "image/png";
  } else {
    debug("probably unsupported image type");
    d->mimeType = "image/" + fixedString;
  }

  d->type = (TagLib::ID3v2::AttachedPictureFrame::Type)data[pos++];
  d->description = readStringField(data, d->textEncoding, &pos);

  d->data = data.mid(pos);
}
Пример #2
0
void Ogg::XiphComment::addField(const String &key, const String &value, bool replace)
{
  if(replace)
    removeField(key.upper());

  if(!key.isEmpty() && !value.isEmpty())
    d->fieldListMap[key.upper()].append(value);
}
Пример #3
0
int main() {
	String a = "Hello ", b = "world!";
	String c = a.concat(b);

	a.print();
	b.print();
	c.print();

	c.upper();
	c.print();

	String d= c.first(3);
	d.print();

	String e = c.last(3);
	e.print();

	String f = c.substr(4, 3);
	f.print();

	String g = "   trim  ";
	g.print();
	g.trim().print();

	(a + b).print();

	getc(stdin);

	return 0;
}
Пример #4
0
String Frame::txxxToKey(const String &description)
{
  Map<String, String> &m = txxxMap();
  String d = description.upper();
  if(m.contains(d))
    return m[d];
  return d;
}
Пример #5
0
String Frame::keyToTXXX(const String &s)
{
  static Map<String, String> m;
  if(m.isEmpty())
    for(size_t i = 0; i < txxxFrameTranslationSize; ++i)
      m[txxxFrameTranslation[i][1]] = txxxFrameTranslation[i][0];
  if(m.contains(s.upper()))
    return m[s];
  return s;
}
Пример #6
0
ByteVector Frame::keyToFrameID(const String &s)
{
    static Map<String, ByteVector> m;
    if(m.isEmpty())
        for(size_t i = 0; i < frameTranslationSize; ++i)
            m[frameTranslation[i][1]] = frameTranslation[i][0];
    if(m.contains(s.upper()))
        return m[s];
    return ByteVector::null;
}
Пример #7
0
PropertyMap UnsynchronizedLyricsFrame::asProperties() const
{
  PropertyMap map;
  String key = description().upper();
  if(key.isEmpty() || key.upper() == "LYRICS")
    map.insert("LYRICS", text());
  else
    map.insert("LYRICS:" + key, text());
  return map;
}
Пример #8
0
TEST(StringTest, ToUpperLocale) {
  CaseFoldingTestData testDataList[] = {
      {
          "Turkic input", turkicInput, turkicLocales,
          sizeof(turkicLocales) / sizeof(const char*),
          "IS\xC4\xB0\xC4\xB0 \xC4\xB0SII",
      },
      {
          "Turkic input", turkicInput, nonTurkicLocales,
          sizeof(nonTurkicLocales) / sizeof(const char*),
          "ISI\xC4\xB0 \xC4\xB0SII",
      },
      {
          "Greek input", greekInput, greekLocales,
          sizeof(greekLocales) / sizeof(const char*),
          "\xCE\x9F\xCE\x94\xCE\x9F\xCE\xA3 \xCE\x9F\xCE\x94\xCE\x9F\xCE\xA3 "
          "\xCE\xA3\xCE\x9F \xCE\xA3\xCE\x9F \x4F\xCE\xA3 \xCE\x9F\xCE\xA3 "
          "\xCE\xA3 \xCE\x95\xCE\x9E",
      },
      {
          "Greek input", greekInput, nonGreekLocales,
          sizeof(nonGreekLocales) / sizeof(const char*),
          "\xCE\x9F\xCE\x94\xCE\x8C\xCE\xA3 \xCE\x9F\xCE\x94\xCE\x8C\xCE\xA3 "
          "\xCE\xA3\xCE\x9F \xCE\xA3\xCE\x9F \x4F\xCE\xA3 \xCE\x9F\xCE\xA3 "
          "\xCE\xA3 \xE1\xBC\x9D\xCE\x9E",
      },
      {
          "Lithuanian input", lithuanianInput, lithuanianLocales,
          sizeof(lithuanianLocales) / sizeof(const char*),
          "I \xC3\x8F J J\xCC\x88 \xC4\xAE \xC4\xAE\xCC\x88 \xC3\x8C \xC3\x8D "
          "\xC4\xA8 XI\xCC\x88 XJ\xCC\x88 X\xC4\xAE\xCC\x88 XI\xCC\x80 "
          "XI\xCC\x81 XI\xCC\x83 XI X\xC3\x8F XJ XJ\xCC\x88 X\xC4\xAE "
          "X\xC4\xAE\xCC\x88",
      },
      {
          "Lithuanian input", lithuanianInput, nonLithuanianLocales,
          sizeof(nonLithuanianLocales) / sizeof(const char*),
          "I \xC3\x8F J J\xCC\x88 \xC4\xAE \xC4\xAE\xCC\x88 \xC3\x8C \xC3\x8D "
          "\xC4\xA8 XI\xCC\x87\xCC\x88 XJ\xCC\x87\xCC\x88 "
          "X\xC4\xAE\xCC\x87\xCC\x88 XI\xCC\x87\xCC\x80 XI\xCC\x87\xCC\x81 "
          "XI\xCC\x87\xCC\x83 XI X\xC3\x8F XJ XJ\xCC\x88 X\xC4\xAE "
          "X\xC4\xAE\xCC\x88",
      },
  };

  for (size_t i = 0; i < sizeof(testDataList) / sizeof(testDataList[0]); ++i) {
    const char* expected = testDataList[i].expected;
    String source = String::fromUTF8(testDataList[i].source);
    for (size_t j = 0; j < testDataList[i].localeListLength; ++j) {
      const char* locale = testDataList[i].localeList[j];
      EXPECT_STREQ(expected, source.upper(locale).utf8().data())
          << testDataList[i].sourceDescription << "; locale=" << locale;
    }
  }
}
Пример #9
0
void APE::Tag::addValue(const String &key, const String &value, bool replace)
{
  if(replace)
    removeItem(key);
  if(!value.isEmpty()) {
    if(d->itemListMap.contains(key) || !replace)
      d->itemListMap[key.upper()].appendValue(value);
    else
      setItem(key, Item(key, value));
  }
}
Пример #10
0
String XMLHttpRequest::uppercaseKnownHTTPMethod(const String& method)
{
    if (equalIgnoringCase(method, "COPY") || equalIgnoringCase(method, "DELETE") || equalIgnoringCase(method, "GET")
        || equalIgnoringCase(method, "HEAD") || equalIgnoringCase(method, "INDEX") || equalIgnoringCase(method, "LOCK")
        || equalIgnoringCase(method, "M-POST") || equalIgnoringCase(method, "MKCOL") || equalIgnoringCase(method, "MOVE")
        || equalIgnoringCase(method, "OPTIONS") || equalIgnoringCase(method, "POST") || equalIgnoringCase(method, "PROPFIND")
        || equalIgnoringCase(method, "PROPPATCH") || equalIgnoringCase(method, "PUT") || equalIgnoringCase(method, "UNLOCK")) {
        return method.upper();
    }
    return method;
}
Пример #11
0
PropertyMap UnsynchronizedLyricsFrame::asProperties() const
{
  PropertyMap map;
  String key = description().upper();
  if(key.isEmpty() || key.upper() == "LYRICS")
    map.insert("LYRICS", text());
  else if(key.isNull())
    map.unsupportedData().append(L"USLT/" + description());
  else
    map.insert("LYRICS:" + key, text());
  return map;
}
Пример #12
0
PropertyMap UserUrlLinkFrame::asProperties() const
{
  PropertyMap map;
  String key = PropertyMap::prepareKey(description());
  if(key.isEmpty() || key.upper() == "URL")
    map.insert("URL", url());
  else if(key.isNull())
    map.unsupportedData().append(L"WXXX/" + description());
  else
    map.insert("URL:" + key, url());
  return map;
}
Пример #13
0
void XMLHttpRequest::open(const String& method, const KURL& url, bool async, ExceptionCode& ec)
{
    internalAbort();
    State previousState = m_state;
    m_state = UNSENT;
    m_error = false;
#if ENABLE(XHR_RESPONSE_BLOB)
    m_asBlob = false;
#endif
    m_uploadComplete = false;

    // clear stuff from possible previous load
    clearResponse();
    clearRequest();

    ASSERT(m_state == UNSENT);

    if (!isValidToken(method)) {
        ec = SYNTAX_ERR;
        return;
    }

    // Method names are case sensitive. But since Firefox uppercases method names it knows, we'll do the same.
    String methodUpper(method.upper());

    if (methodUpper == "TRACE" || methodUpper == "TRACK" || methodUpper == "CONNECT") {
        ec = SECURITY_ERR;
        return;
    }

    m_url = url;

    if (methodUpper == "COPY" || methodUpper == "DELETE" || methodUpper == "GET" || methodUpper == "HEAD"
        || methodUpper == "INDEX" || methodUpper == "LOCK" || methodUpper == "M-POST" || methodUpper == "MKCOL" || methodUpper == "MOVE"
        || methodUpper == "OPTIONS" || methodUpper == "POST" || methodUpper == "PROPFIND" || methodUpper == "PROPPATCH" || methodUpper == "PUT"
        || methodUpper == "UNLOCK")
        m_method = methodUpper;
    else
        m_method = method;

    m_async = async;

    ASSERT(!m_loader);

    // Check previous state to avoid dispatching readyState event
    // when calling open several times in a row.
    if (previousState != OPENED)
        changeState(OPENED);
    else
        m_state = OPENED;
}
PropertyMap UserTextIdentificationFrame::asProperties() const
{
  String tagName = description();

  PropertyMap map;
  String key = tagName.upper();
  if(key.isNull()) // this frame's description is not a valid PropertyMap key -> add to unsupported list
    map.unsupportedData().append(L"TXXX/" + description());
  else {
    StringList v = fieldList();
    for(StringList::ConstIterator it = v.begin(); it != v.end(); ++it)
      if(*it != description())
        map.insert(key, *it);
  }
  return map;
}
Пример #15
0
void XMLHttpRequest::open(const String& method, const KURL& url, bool async, const String& user, const String& password, ExceptionCode& ec)
{
    abort();
    m_aborted = false;

    // clear stuff from possible previous load
    m_requestHeaders = DeprecatedString();
    m_responseHeaders = String();
    m_response = DeprecatedString();
    m_createdDocument = false;
    m_responseXML = 0;

    changeState(Uninitialized);

    if (m_aborted)
        return;

    if (!urlMatchesDocumentDomain(url))
        return;

    if (!isValidToken(method)) {
        ec = SYNTAX_ERR;
        return;
    }
    
    m_url = url;

    if (!user.isNull())
        m_url.setUser(user.deprecatedString());

    if (!password.isNull())
        m_url.setPass(password.deprecatedString());

    // Method names are case sensitive. But since Firefox uppercases method names it knows, we'll do the same.
    String methodUpper(method.upper());
    if (methodUpper == "CONNECT" || methodUpper == "COPY" || methodUpper == "DELETE" || methodUpper == "GET" || methodUpper == "HEAD"
        || methodUpper == "INDEX" || methodUpper == "LOCK" || methodUpper == "M-POST" || methodUpper == "MKCOL" || methodUpper == "MOVE" 
        || methodUpper == "OPTIONS" || methodUpper == "POST" || methodUpper == "PROPFIND" || methodUpper == "PROPPATCH" || methodUpper == "PUT" 
        || methodUpper == "TRACE" || methodUpper == "UNLOCK")
        m_method = methodUpper.deprecatedString();
    else
        m_method = method.deprecatedString();

    m_async = async;

    changeState(Loading);
}
void DumpRenderTreeSupportGtk::doCommand(WebKitWebView* webView, const char* command)
{
    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
    Frame& frame = core(webView)->focusController().focusedOrMainFrame();
    Editor& editor = frame.editor();

    String commandString(command);
    // Remove ending : here.
    if (commandString.endsWith(":", true))
        commandString = commandString.left(commandString.length() - 1);

    // Make the first char in upper case.
    String firstChar = commandString.left(1);
    commandString = commandString.right(commandString.length() - 1);
    commandString.insert(firstChar.upper(), 0);

    editor.command(commandString).execute();
}
Пример #17
0
void APE::Tag::removeItem(const String &key)
{
  Map<const String, Item>::Iterator it = d->itemListMap.find(key.upper());
  if(it != d->itemListMap.end())
    d->itemListMap.erase(it);
}
Пример #18
0
void APE::Tag::setItem(const String &key, const Item &item)
{
  d->itemListMap.insert(key.upper(), item);
}