void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) { RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this); // To preserve comments, remove only the text nodes, then add a single text node. WillBeHeapVector<RefPtrWillBeMember<Node>> textNodes; for (Node* n = firstChild(); n; n = n->nextSibling()) { if (n->isTextNode()) textNodes.append(n); } size_t size = textNodes.size(); for (size_t i = 0; i < size; ++i) removeChild(textNodes[i].get(), IGNORE_EXCEPTION); // Normalize line endings. String value = defaultValue; value.replace("\r\n", "\n"); value.replace('\r', '\n'); insertBefore(document().createTextNode(value), firstChild(), IGNORE_EXCEPTION); if (!m_isDirty) setNonDirtyValue(value); }
String ApLib::InsertConfigModuleTokens(const char* szModuleName, const char* szConfigValue) { String sValue = szConfigValue; String sModuleLibraryPath = Apollo::getModuleLibraryPath(szModuleName); String sModuleResourcePath = Apollo::getModuleResourcePath(szModuleName); { List lReplace; lReplace.AddLast(String::filenamePathSeparator(), "/"); sValue.replace(lReplace); sModuleLibraryPath.replace(lReplace); sModuleResourcePath.replace(lReplace); } { List lReplace; lReplace.AddLast(sModuleLibraryPath, ModuleLibraryPathToken() + "/"); lReplace.AddLast(sModuleResourcePath, ModuleResourcePathToken() + "/"); if (sValue.replace(lReplace)) { return sValue; } // Config value is a path, return replaced and normalized else {} // Not a (known to be) path, leave untouched } return szConfigValue; }
static String platformLanguage() { char* localeDefault = setlocale(LC_CTYPE, 0); if (!localeDefault) return String("c"); String locale = String(localeDefault); locale.replace('_', '-'); size_t position = locale.find('.'); if (position != notFound) locale = locale.left(position); return locale; }
void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) { // To preserve comments, remove only the text nodes, then add a single text node. Vector<RefPtr<Node> > textNodes; for (Node* n = firstChild(); n; n = n->nextSibling()) { if (n->isTextNode()) textNodes.append(n); } ExceptionCode ec; size_t size = textNodes.size(); for (size_t i = 0; i < size; ++i) removeChild(textNodes[i].get(), ec); // Normalize line endings. String value = defaultValue; value.replace("\r\n", "\n"); value.replace('\r', '\n'); insertBefore(document()->createTextNode(value), firstChild(), ec); if (!m_isDirty) setNonDirtyValue(value); }
/*============================================*/ String WIFI::showStatus(void) { Serial1.println("AT+ShowSTA"); //发送AT指令 String data; while (1) { if(Serial1.available()>0) { char a =Serial1.read(); data=data+a; } if (data.indexOf("done")!=-1) { break; } } char head[4] = {0x0D,0x0A}; //头部多余字符串 char tail[7] = {0x0D,0x0A,0x0D,0x0A}; //尾部多余字符串 data.replace("AT+ShowSTA",""); data.replace("done",""); data.replace(head,""); data.replace(tail,""); return data; }
void WebContextMenuClient::searchWithGoogle(const Frame* frame) { String searchString = frame->selectedText(); searchString.stripWhiteSpace(); String encoded = encodeWithURLEscapeSequences(searchString); encoded.replace("%20", "+"); String url("http://www.google.com/search?q="); url.append(encoded); url.append("&ie=UTF-8&oe=UTF-8"); ResourceRequest request = ResourceRequest(url); if (Page* page = frame->page()) page->mainFrame()->loader()->urlSelected(FrameLoadRequest(request), 0, false, true); }
static String applySVGWhitespaceRules(const String& string, bool preserveWhiteSpace) { String newString = string; if (preserveWhiteSpace) { // Spec: When xml:space="preserve", the SVG user agent will do the following using a // copy of the original character data content. It will convert all newline and tab // characters into space characters. Then, it will draw all space characters, including // leading, trailing and multiple contiguous space characters. newString.replace('\t', ' '); newString.replace('\n', ' '); newString.replace('\r', ' '); return newString; } // Spec: When xml:space="default", the SVG user agent will do the following using a // copy of the original character data content. First, it will remove all newline // characters. Then it will convert all tab characters into space characters. // Then, it will strip off all leading and trailing space characters. // Then, all contiguous space characters will be consolidated. newString.replace('\n', emptyString()); newString.replace('\r', emptyString()); newString.replace('\t', ' '); return newString; }
void ProjectManager::_favorite_pressed(Node *p_hb) { String clicked = p_hb->get_meta("name"); bool favorite = !p_hb->get_meta("favorite"); String proj=clicked.replace(":::",":/"); proj=proj.replace("::","/"); if (favorite) { EditorSettings::get_singleton()->set("favorite_projects/"+clicked,proj); } else { EditorSettings::get_singleton()->erase("favorite_projects/"+clicked); } EditorSettings::get_singleton()->save(); _load_recent_projects(); }
//--------------------------------- void Utils::stringFindAndReplace ( String &source, const String searchString, const String replaceString ) { size_t found = source.find ( searchString ); if ( found != String::npos ) { size_t searchStrLength = searchString.length(); size_t replaceStrLength = replaceString.length(); do { source.replace ( found, searchStrLength, replaceString ); found = source.find (searchString, found + replaceStrLength ); } while ( found != String::npos ); } }
String WIFI::showAP(void) { String data; _cell.flush(); _cell.print("AT+CWLAP\r\n"); delay(1000); while(1); unsigned long start; start = millis(); while (millis()-start<8000) { if(_cell.available()>0) { char a =_cell.read(); data=data+a; } if (data.indexOf("OK")!=-1 || data.indexOf("ERROR")!=-1 ) { break; } } if(data.indexOf("ERROR")!=-1) { return "ERROR"; } else{ char head[4] = {0x0D,0x0A}; char tail[7] = {0x0D,0x0A,0x0D,0x0A}; data.replace("AT+CWLAP",""); data.replace("OK",""); data.replace("+CWLAP","WIFI"); data.replace(tail,""); data.replace(head,""); return data; } }
/************************************************************************* //show the current ip address return: string of ip address ***************************************************************************/ String WIFI::showIP(void) { String data; unsigned long start; //DBG("AT+CIFSR\r\n"); for(int a=0; a<3;a++) { _cell.println("AT+CIFSR"); start = millis(); while (millis()-start<3000) { while(_cell.available()>0) { char a =_cell.read(); data=data+a; } if (data.indexOf("AT+CIFSR")!=-1) { break; } } if(data.indexOf(".") != -1) { break; } data = ""; } //DBG(data); //DBG("\r\n"); char head[4] = {0x0D,0x0A}; char tail[7] = {0x0D,0x0D,0x0A}; data.replace("AT+CIFSR",""); data.replace(tail,""); data.replace(head,""); return data; }
void Win32Core::moveDiskItem(const String& itemPath, const String& destItemPath) { SHFILEOPSTRUCT op; ZeroMemory(&op, sizeof(SHFILEOPSTRUCT)); String fromPath = itemPath.replace("/", "\\"); String toPath =destItemPath.replace("/", "\\"); fromPath.append('\0'); toPath.append('\0'); printf("Moving %s to %s\n", fromPath.c_str(), toPath.c_str()); op.hwnd = hWnd; op.wFunc = FO_MOVE; op.pFrom = fromPath.getWDataWithEncoding(String::ENCODING_UTF8); op.pTo = toPath.getWDataWithEncoding(String::ENCODING_UTF8); op.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR; int ret = SHFileOperation(&op); if(ret != 0) { String err = error_to_string(ret); printf("MOVE ERROR: %s\n", err.c_str()); } }
String FileAccess::fix_path(const String& p_path) const { //helper used by file accesses that use a single filesystem String r_path = p_path.replace("\\", "/"); switch(_access_type) { case ACCESS_RESOURCES: { if (Globals::get_singleton()) { if (r_path.begins_with("res://")) { String resource_path = Globals::get_singleton()->get_resource_path(); if (resource_path != "") { return r_path.replace("res:/",resource_path); }; return r_path.replace("res://", ""); } } } break; case ACCESS_USERDATA: { if (r_path.begins_with("user://")) { String data_dir=OS::get_singleton()->get_data_dir(); if (data_dir != "") { return r_path.replace("user:/",data_dir); }; return r_path.replace("user://", ""); } } break; case ACCESS_FILESYSTEM: { return r_path; } break; } return r_path; }
HRESULT DOMHTMLInputElement::replaceCharactersInRange(int startTarget, int endTarget, _In_ BSTR replacementString, int index) { if (!replacementString) return E_POINTER; ASSERT(is<HTMLInputElement>(m_element)); HTMLInputElement& inputElement = downcast<HTMLInputElement>(*m_element); String newValue = inputElement.value(); String webCoreReplacementString(static_cast<UChar*>(replacementString), SysStringLen(replacementString)); newValue.replace(startTarget, endTarget - startTarget, webCoreReplacementString); inputElement.setValue(newValue); inputElement.setSelectionRange(index, newValue.length()); return S_OK; }
String FilePath::GetFrameworkPathForPrefix( const String &typePrefix, const ePathType pType) const { DVASSERT(!typePrefix.empty()); String prefixPathname = GetSystemPathname(typePrefix, pType); String::size_type pos = absolutePathname.find(prefixPathname); if(pos == 0) { String pathname = absolutePathname; pathname = pathname.replace(pos, prefixPathname.length(), typePrefix); return pathname; } return String(); }
void WebContextMenuClient::searchWithGoogle(const Frame* frame) { String searchString = frame->editor().selectedText(); searchString.stripWhiteSpace(); String encoded = encodeWithURLEscapeSequences(searchString); encoded.replace("%20", "+"); String url("http://www.google.com/search?q="); url.append(encoded); url.append("&ie=UTF-8&oe=UTF-8"); if (Page* page = frame->page()) { UserGestureIndicator indicator(DefinitelyProcessingUserGesture); page->mainFrame().loader().urlSelected(URL(ParsedURLString, url), String(), 0, LockHistory::No, LockBackForwardList::No, MaybeSendReferrer); } }
String Shader::ResolveIncludes(const String &source) { String fullSource = source; String includeDirective = "#pragma include "; size_t found = fullSource.find(includeDirective); while (found != String::npos) { size_t startPos = found + includeDirective.length(); size_t endPos = fullSource.find("\n", startPos); String fileName = fullSource.substr(startPos, endPos - startPos); String includedFileText = ContentLoader::FileReadAll(ContentLoader::ContentPath + fileName); fullSource.replace(found, endPos - found, includedFileText); found = fullSource.find(includeDirective); } return fullSource; }
static TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Document& document) { String normalizedAcceptCharset = acceptCharset; normalizedAcceptCharset.replace(',', ' '); Vector<String> charsets; normalizedAcceptCharset.split(' ', charsets); for (auto& charset : charsets) { TextEncoding encoding(charset); if (encoding.isValid()) return encoding; } return document.textEncoding(); }
void CubemapEditorDialog::LoadCubemap(const QString& path) { FilePath filePath(path.toStdString()); TextureDescriptor* texDescriptor = TextureDescriptor::CreateFromFile(filePath); if(NULL != texDescriptor && texDescriptor->IsCubeMap()) { String fileNameWithoutExtension = filePath.GetFilename(); String extension = filePath.GetExtension(); fileNameWithoutExtension.replace(fileNameWithoutExtension.find(extension), extension.size(), ""); bool cubemapLoadResult = true; for(int i = 0; i < CubemapUtils::GetMaxFaces(); ++i) { if(texDescriptor->dataSettings.faceDescription & (1 << CubemapUtils::MapUIToFrameworkFace(i))) { FilePath faceFilePath = filePath; faceFilePath.ReplaceFilename(fileNameWithoutExtension + CubemapUtils::GetFaceNameSuffix(CubemapUtils::MapUIToFrameworkFace(i)) + "." + CubemapUtils::GetDefaultFaceExtension()); bool faceLoadResult = LoadImageTo(faceFilePath.GetAbsolutePathname(), i, true); cubemapLoadResult = cubemapLoadResult && faceLoadResult; } } if(!cubemapLoadResult) { ShowErrorDialog("This cubemap texture seems to be damaged.\nPlease repair it by setting image(s) to empty face(s) and save to disk."); } } else { if(NULL == texDescriptor) { ShowErrorDialog("Failed to load cubemap texture " + path.toStdString()); } else { ShowErrorDialog("Failed to load cubemap texture " + path.toStdString() + ". Seems this is not a cubemap texture."); } } SafeDelete(texDescriptor); }
EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p_path) { if (!filesystem || scanning) return NULL; String f = ProjectSettings::get_singleton()->localize_path(p_path); if (!f.begins_with("res://")) return NULL; f = f.substr(6, f.length()); f = f.replace("\\", "/"); if (f == String()) return filesystem; if (f.ends_with("/")) f = f.substr(0, f.length() - 1); Vector<String> path = f.split("/"); if (path.size() == 0) return NULL; EditorFileSystemDirectory *fs = filesystem; for (int i = 0; i < path.size(); i++) { int idx = -1; for (int j = 0; j < fs->get_subdir_count(); j++) { if (fs->get_subdir(j)->get_name() == path[i]) { idx = j; break; } } if (idx == -1) { return NULL; } else { fs = fs->get_subdir(idx); } } return fs; }
String RenameDialog::_postprocess(const String &subject) { int style_id = opt_style->get_selected(); String result = subject; if (style_id == 1) { // CamelCase to Under_Line result = result.camelcase_to_underscore(true); result = _regex("_+", result, "_"); } else if (style_id == 2) { // Under_Line to CamelCase RegEx pattern("_+(.?)"); Array matches = pattern.search_all(result); // _ name would become empty. Ignore if (matches.size() && result != "_") { String buffer; int start = 0; int end = 0; for (int i = 0; i < matches.size(); ++i) { start = ((Ref<RegExMatch>)matches[i])->get_start(1); buffer += result.substr(end, start - end - 1); buffer += result.substr(start, 1).to_upper(); end = start + 1; } buffer += result.substr(end, result.size() - (end + 1)); result = buffer.replace("_", "").capitalize(); } } int case_id = opt_case->get_selected(); if (case_id == 1) { // To Lowercase result = result.to_lower(); } else if (case_id == 2) { // To Upercase result = result.to_upper(); } return result; }
void replaceNewlinesWithWindowsStyleNewlines(String& str) { DEFINE_STATIC_LOCAL(String, windowsNewline, ("\r\n")); const static unsigned windowsNewlineLength = windowsNewline.length(); unsigned index = 0; unsigned strLength = str.length(); while (index < strLength) { if (str[index] != '\n' || (index > 0 && str[index - 1] == '\r')) { ++index; continue; } str.replace(index, 1, windowsNewline); strLength = str.length(); index += windowsNewlineLength; } }
String StructureShape::propertyHash() { ASSERT(m_final); if (m_propertyHash) return *m_propertyHash; StringBuilder builder; builder.append(":"); for (auto iter = m_fields.begin(), end = m_fields.end(); iter != end; ++iter) { String property = String(iter->key); property.replace(":", "\\:"); // Ensure that hash({"foo:", "bar"}) != hash({"foo", ":bar"}) because we're using colons as a separator and colons are legal characters in field names in JS. builder.append(property); } m_propertyHash = std::make_unique<String>(builder.toString()); return *m_propertyHash; }
String TextCodecICU::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError) { // Get a converter for the passed-in encoding. if (!m_converterICU) { createICUConverter(); ASSERT(m_converterICU); if (!m_converterICU) { LOG_ERROR("error creating ICU encoder even though encoding was in table"); return String(); } } ErrorCallbackSetter callbackSetter(m_converterICU, stopOnError); StringBuilder result; UChar buffer[ConversionBufferSize]; UChar* bufferLimit = buffer + ConversionBufferSize; const char* source = reinterpret_cast<const char*>(bytes); const char* sourceLimit = source + length; int32_t* offsets = NULL; UErrorCode err = U_ZERO_ERROR; do { int ucharsDecoded = decodeToBuffer(buffer, bufferLimit, source, sourceLimit, offsets, flush, err); result.append(buffer, ucharsDecoded); } while (err == U_BUFFER_OVERFLOW_ERROR); if (U_FAILURE(err)) { // flush the converter so it can be reused, and not be bothered by this error. do { decodeToBuffer(buffer, bufferLimit, source, sourceLimit, offsets, true, err); } while (source < sourceLimit); sawError = true; } String resultString = result.toString(); // <http://bugs.webkit.org/show_bug.cgi?id=17014> // Simplified Chinese pages use the code A3A0 to mean "full-width space", but ICU decodes it as U+E5E5. // FIXME: strcasecmp is locale sensitive, we should not be using it. if (strcmp(m_encodingName, "GBK") == 0 || strcasecmp(m_encodingName, "gb18030") == 0) resultString.replace(0xE5E5, ideographicSpace); return resultString; }
void TranslationServer::set_locale(const String& p_locale) { // replaces '-' with '_' for macOS Sierra-style locales String univ_locale = p_locale.replace("-", "_"); if(!is_valid_locale(univ_locale)) { String trimmed_locale = get_trimmed_locale(univ_locale); ERR_EXPLAIN("Invalid Locale: "+trimmed_locale); ERR_FAIL_COND(!is_valid_locale(trimmed_locale)); locale=trimmed_locale; } else { locale=univ_locale; } }
int set(String args) { //Clear LCD lcd.clear(); lcd.setCursor(0, 0); //Replace characters args.replace("%20", " "); args.replace("%27", "'"); printWords(args); //Schedule flash flash_counter = 5; return 0; }
void foldQuoteMarksAndSoftHyphens(String& s) { s.replace(hebrewPunctuationGeresh, '\''); s.replace(hebrewPunctuationGershayim, '"'); s.replace(leftDoubleQuotationMark, '"'); s.replace(leftSingleQuotationMark, '\''); s.replace(rightDoubleQuotationMark, '"'); s.replace(rightSingleQuotationMark, '\''); // Replace soft hyphen with an ignorable character so that their presence or absence will // not affect string comparison. s.replace(softHyphen, 0); }
static void scanDirectoryForDicionaries(const char* directoryPath, HashMap<AtomicString, Vector<String>>& availableLocales) { for (const auto& filePath : listDirectory(directoryPath, "hyph_*.dic")) { String locale = extractLocaleFromDictionaryFilePath(filePath).convertToASCIILowercase(); availableLocales.add(locale, Vector<String>()).iterator->value.append(filePath); String localeReplacingUnderscores = String(locale); localeReplacingUnderscores.replace('_', '-'); if (locale != localeReplacingUnderscores) availableLocales.add(localeReplacingUnderscores, Vector<String>()).iterator->value.append(filePath); size_t dividerPosition = localeReplacingUnderscores.find('-'); if (dividerPosition != notFound) { localeReplacingUnderscores.truncate(dividerPosition); availableLocales.add(localeReplacingUnderscores, Vector<String>()).iterator->value.append(filePath); } } }
static void replaceCharsetInMediaType(String& mediaType, const String& charsetValue) { unsigned int pos = 0, len = 0; findCharsetInMediaType(mediaType, pos, len); if (!len) { // When no charset found, do nothing. return; } // Found at least one existing charset, replace all occurrences with new charset. while (len) { mediaType.replace(pos, len, charsetValue); unsigned int start = pos + charsetValue.length(); findCharsetInMediaType(mediaType, pos, len, start); } }
void WikiParser::extractSourcecode(String &Text) { String Tmp; Text.pregReplace("/^\\\\code$/im","<source>"); Text.pregReplace("/^\\\\endcode$/im","</source>"); Text.pregReplace("/<sourcecode>/i","<source>"); Text.pregReplace("/</sourcecode>/i","</source>"); Array matches; //while (Text.PregMatch("/^(.*)<source.*?>[\\n]*(.*?)<\\/source>(.*)$/ism")) { // Die Verwendung von .*? hinter source führt dazu, dass das Parsen ewig lange dauert! while (Text.pregMatch("/^(.*)<source>[\\n]*(.*?)<\\/source>(.*)$/ism",matches)) { sourcecount++; Tmp=matches[2]; Tmp.replace("\t"," "); source.set(sourcecount,Tmp); Text.setf("%s<source %i>%s",matches.getPtr(1),sourcecount,matches.getPtr(3)); } }