static bool IsCaseChangeableChar(uint32_t aChar) { return IS_IN_BMP(aChar) && ToLowerCase(static_cast<char16_t>(aChar)) != ToUpperCase(static_cast<char16_t>(aChar)); }
/* static */ void txXPathNodeUtils::getLocalName(const txXPathNode& aNode, nsAString& aLocalName) { if (aNode.isDocument()) { aLocalName.Truncate(); return; } if (aNode.isContent()) { if (aNode.mNode->IsNodeOfType(nsINode::eELEMENT)) { nsINodeInfo* nodeInfo = aNode.Content()->NodeInfo(); nodeInfo->GetLocalName(aLocalName); // Check for html if (nodeInfo->NamespaceEquals(kNameSpaceID_None) && aNode.mNode->IsNodeOfType(nsINode::eHTML)) { ToUpperCase(aLocalName); } return; } if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) { // PIs don't have a nodeinfo but do have a name nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode.mNode); node->GetNodeName(aLocalName); return; } aLocalName.Truncate(); return; } aNode.Content()->GetAttrNameAt(aNode.mIndex)->LocalName()-> ToString(aLocalName); // Check for html if (aNode.Content()->NodeInfo()->NamespaceEquals(kNameSpaceID_None) && aNode.Content()->IsNodeOfType(nsINode::eHTML)) { ToUpperCase(aLocalName); } }
bool vrResourceManager::AddTexture( vrTexture *texture_p ) { assert( texture_p ); if ( !texture_p ) return false; ToUpperCase( texture_p->cName ); if ( t_list ) t_list->insert( t_list->end(), texture_p ); return true; }
bool Tokenizer::IsWordFirst(const char aInput) const { // TODO: make this fully work with unicode return (ToLowerCase(static_cast<uint32_t>(aInput)) != ToUpperCase(static_cast<uint32_t>(aInput))) || '_' == aInput || (mAdditionalWordChars ? !!strchr(mAdditionalWordChars, aInput) : false); }
uint32_t ToTitleCase(uint32_t aChar) { if (IS_ASCII(aChar)) { return ToUpperCase(aChar); } return mozilla::unicode::GetTitlecaseForLower(aChar); }
bool vrResourceManager::AddObject( vrTriObject2 *object_p ) { assert( object_p ); assert( o_list ); if ( !object_p ) return false; ToUpperCase( object_p->cName ); if ( o_list ) o_list->insert( o_list->end(), object_p ); return true; }
// make a search for the user's input // inside the database of the program void TechBot::selectMatch() { std::fstream outfile("keywords.txt", std::ios::out); RespLISTonse.clear(); // introduce thse new "string variable" to help // support the implementation of keyword ranking // during the matching process std::string bestKeyWord; Vstr ListOfWord; if(TB_Input.find("**") == std::string::npos) { RightClear(TB_Input, "."); ToUpperCase(TB_Input); SplitToWords(TB_Input, ListOfWord); bestKeyWord = findBestKey(ListOfWord); TB_KeyWord = bestKeyWord; } else { TB_KeyWord = TB_Input; } bool found=false; for(mapString ::iterator it=KnowledgeBase.begin();it!=KnowledgeBase.end();it++) { std::string temp=it->first; if((std::string)temp==(std::string)TB_KeyWord) found=true; } if(!found) { for(mapString ::iterator it=KnowledgeBase.begin();it!=KnowledgeBase.end();it++) { std::string temp=it->first; if(temp.find(TB_Input)!=std::string::npos) { found=true; } } } if(found) { std::string tt=TB_KeyWord; std::vector<TBResponse> RespLISTObj = KnowledgeBase[tt]; RespListgetter(RespLISTObj); } }
/* static */ void txXPathNodeUtils::getNodeName(const txXPathNode& aNode, nsAString& aName) { if (aNode.isDocument()) { aName.Truncate(); return; } if (aNode.isContent()) { if (aNode.mNode->IsElement()) { nsINodeInfo* nodeInfo = aNode.Content()->NodeInfo(); nodeInfo->GetQualifiedName(aName); // Check for html if (aNode.Content()->IsHTML() && aNode.Content()->IsInHTMLDocument()) { ToUpperCase(aName); } return; } if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) { // PIs don't have a nodeinfo but do have a name nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode.mNode); node->GetNodeName(aName); return; } aName.Truncate(); return; } aNode.Content()->GetAttrNameAt(aNode.mIndex)->GetQualifiedName(aName); // Check for html if (aNode.Content()->IsHTML()) { ToUpperCase(aName); } }
void ToUpperCase(const nsAString& aSource, nsAString& aDest) { const char16_t *in; char16_t *out; uint32_t len = NS_StringGetData(aSource, &in); NS_StringGetMutableData(aDest, len, &out); NS_ASSERTION(out, "Uh..."); ToUpperCase(in, out, len); }
//----------------------------------------------------------------------- void ToFirstLetterCapitalised(std::string& str) { std::string strLower=str; std::string strUpper=str; ToLowerCase(strLower); ToUpperCase(strUpper); if(strUpper.length() > 0) str=strUpper.substr(0,1); if(strLower.length() > 1) str=str+strLower.substr(1,strLower.length()-1); }
void ToUpperCase(const nsAString& aSource, nsAString& aDest) { const PRUnichar *in; PRUnichar *out; PRUint32 len = NS_StringGetData(aSource, &in); NS_StringGetMutableData(aDest, len, &out); NS_ASSERTION(out, "Uh..."); ToUpperCase(in, out, len); }
void ToUpperCase(const nsAString& aSource, nsAString& aDest) { const char16_t *in = aSource.BeginReading(); uint32_t len = aSource.Length(); aDest.SetLength(len); char16_t *out = aDest.BeginWriting(); ToUpperCase(in, out, len); }
PRUint32 FontAliasKey::HashCode(void) const { PRUint32 hash = 0; const PRUnichar* string = mString.get(); PRUnichar ch; while ((ch = *string++) != 0) { // FYI: hash = hash*37 + ch ch = ToUpperCase(ch); hash = ((hash << 5) + (hash << 2) + hash) + ch; } return hash; }
void TechBot::welcome_user() { std::cout<<"What is your name?\n>"; std::getline(std::cin,user_name); ToUpperCase(user_name); for(int i=user_name.length()-1;i>=0;i--) { if(user_name[i]==' ') {user_name=user_name.substr(i+1,user_name.length()-i+1);break;} } std::cout<<"Hi "<<user_name<<std::endl; }
/* readonly attribute DOMString DisplayVendorID; */ NS_IMETHODIMP nsSystemInfo::GetDisplayVendorID(nsAString & aDisplayVendorID) { nsCString DeviceId(mDeviceID); ToUpperCase(DeviceId); PRInt32 start = DeviceId.Find(NS_LITERAL_CSTRING("VEN_")); PRInt32 end = DeviceId.Find(NS_LITERAL_CSTRING("&"), start); DeviceId.Cut(end, DeviceId.Length()); DeviceId.Cut(0, start + 4); DeviceId.Insert("0x", 0, 2); aDisplayVendorID.AssignLiteral(DeviceId.BeginReading()); return NS_OK; }
// the following block is to append the accesskey to mTitle if there is an accesskey // but the mTitle doesn't have the character void nsTextBoxFrame::UpdateAccessTitle() { /* * Note that if you change appending access key label spec, * you need to maintain same logic in following methods. See bug 324159. * toolkit/content/commonDialog.js (setLabelForNode) * toolkit/content/widgets/text.xml (formatAccessKey) */ PRInt32 menuAccessKey; nsMenuBarListener::GetMenuAccessKey(&menuAccessKey); if (!menuAccessKey || mAccessKey.IsEmpty()) return; if (!AlwaysAppendAccessKey() && FindInReadable(mAccessKey, mTitle, nsCaseInsensitiveStringComparator())) return; nsAutoString accessKeyLabel; accessKeyLabel += '('; accessKeyLabel += mAccessKey; ToUpperCase(accessKeyLabel); accessKeyLabel += ')'; if (mTitle.IsEmpty()) { mTitle = accessKeyLabel; return; } const nsDependentString& kEllipsis = nsContentUtils::GetLocalizedEllipsis(); PRUint32 offset = mTitle.Length(); if (StringEndsWith(mTitle, kEllipsis)) { offset -= kEllipsis.Length(); } else if (StringEndsWith(mTitle, OLD_ELLIPSIS)) { // Try to check with our old ellipsis (for old addons) offset -= OLD_ELLIPSIS.Length(); } else { // Try to check with // our default ellipsis (for non-localized addons) or ':' const PRUnichar kLastChar = mTitle.Last(); if (kLastChar == PRUnichar(0x2026) || kLastChar == PRUnichar(':')) offset--; } if (InsertSeparatorBeforeAccessKey() && offset > 0 && !NS_IS_SPACE(mTitle[offset - 1])) { mTitle.Insert(' ', offset); offset++; } mTitle.Insert(accessKeyLabel, offset); }
int BrotliTransformDictionaryWord(uint8_t* dst, const uint8_t* word, int len, const BrotliTransforms* transforms, int transform_idx) { int idx = 0; const uint8_t* prefix = BROTLI_TRANSFORM_PREFIX(transforms, transform_idx); uint8_t type = BROTLI_TRANSFORM_TYPE(transforms, transform_idx); const uint8_t* suffix = BROTLI_TRANSFORM_SUFFIX(transforms, transform_idx); { int prefix_len = *prefix++; while (prefix_len--) { dst[idx++] = *prefix++; } } { const int t = type; int i = 0; if (t <= BROTLI_TRANSFORM_OMIT_LAST_9) { len -= t; } else if (t >= BROTLI_TRANSFORM_OMIT_FIRST_1 && t <= BROTLI_TRANSFORM_OMIT_FIRST_9) { int skip = t - (BROTLI_TRANSFORM_OMIT_FIRST_1 - 1); word += skip; len -= skip; } while (i < len) { dst[idx++] = word[i++]; } if (t == BROTLI_TRANSFORM_UPPERCASE_FIRST) { ToUpperCase(&dst[idx - len]); } else if (t == BROTLI_TRANSFORM_UPPERCASE_ALL) { uint8_t* uppercase = &dst[idx - len]; while (len > 0) { int step = ToUpperCase(uppercase); uppercase += step; len -= step; } } } { int suffix_len = *suffix++; while (suffix_len--) { dst[idx++] = *suffix++; } return idx; } }
bool vrResourceManager::AddMaterial( vrMaterial2 *material_p ) { assert( material_p ); assert( m_list ); if ( !material_p ) return false; ToUpperCase( material_p->cName ); if ( m_list ) m_list->insert( m_list->end(), material_p ); return true; }
bool vrResourceManager::AddTexture( LPSTR strFileName ) { assert( t_list ); vrTexture *t = new vrTexture(); if( !t ) return false; if ( !t->LoadFromFile( strFileName )) return false; ToUpperCase( t->cName ); if ( t_list ) t_list->insert( t_list->end(), t ); return true; }
vrTriObject2* vrResourceManager::GetObject( LPSTR strObjectName ) { ToUpperCase( strObjectName ); assert( o_list ); if ( !o_list ) return NULL; O_LIST::iterator i = o_list->begin(); vrTriObject2 *object; while( i != o_list->end() ) { object = *i; ToUpperCase( object->cName ); if ( strncmp( object->cName, strObjectName , 32 ) == 0 ) return object; i++; } return NULL; }
BOOL vrResourceManager::LoadTextures( LPSTR strFileName ) { char buffer[255]; char dummy[255]; char read[255]; int iTexCount = 0; memset( buffer, 0, 255 ); e_log.WriteOut("[STATUS] Parsing Resources from File %s \n", strFileName ); FILE *f = fopen( strFileName, "rt" ); if ( f == NULL ) return FALSE; while ( !feof( f ) ) { while ( (strcmp( buffer, "<texture>") != 0) && (strcmp( buffer, "<texture>\n") != 0 ) ) { if ( feof( f ) ) return TRUE; fgets( (char*)buffer, 255, f ); } //выдел¤ем пам¤ть под текстуру vrTexture *t = new vrTexture(); if ( !t ) return FALSE; while ( strcmp( buffer, "</texture>" ) != 0 )//читаем содержимое структуры { fgets( (char*)read, 255, f ); sscanf( read, "%s %s", buffer, dummy ); ToUpperCase( dummy ); if ( strcmp( buffer, "name" ) == 0 ) strcpy( &t->cName[0], dummy ); else if( strcmp( buffer, "file" ) == 0 ) if ( !t->LoadFromFile ( dummy ) ) return FALSE; } this->AddTexture( t ); iTexCount++; } e_log.WriteOut("[STATUS] %i Textures Loaded \n", iTexCount ); return TRUE; }
void ToUpperCase(const char16_t *aIn, char16_t *aOut, uint32_t aLen) { for (uint32_t i = 0; i < aLen; i++) { uint32_t ch = aIn[i]; if (NS_IS_HIGH_SURROGATE(ch) && i < aLen - 1 && NS_IS_LOW_SURROGATE(aIn[i + 1])) { ch = mozilla::unicode::GetUppercase(SURROGATE_TO_UCS4(ch, aIn[i + 1])); NS_ASSERTION(!IS_IN_BMP(ch), "case mapping crossed BMP/SMP boundary!"); aOut[i++] = H_SURROGATE(ch); aOut[i] = L_SURROGATE(ch); continue; } aOut[i] = ToUpperCase(ch); } }
/* readonly attribute DOMString DisplayChipset; */ NS_IMETHODIMP nsSystemInfo::GetDisplayChipset(nsAString & aDisplayChipset) { nsCString deviceId(mDeviceID); ToUpperCase(deviceId); PRInt32 pos = deviceId.Find(NS_LITERAL_CSTRING("&DEV_")); if (pos != -1) { deviceId.Cut(0, pos + 5); } pos = deviceId.Find(NS_LITERAL_CSTRING("&")); if (pos != -1) { deviceId.Cut(pos, deviceId.Length()); } aDisplayChipset.AssignLiteral("0x"); aDisplayChipset.AppendLiteral(deviceId.BeginReading()); return NS_OK; }
LogLevel GetLogLevel(const string& lvl) { string level = ToUpperCase(lvl); if (level == "ANY") return lAny; if (level == "DEBUG5") return lDebug5; if (level == "DEBUG4") return lDebug4; if (level == "DEBUG3") return lDebug3; if (level == "DEBUG2") return lDebug2; if (level == "DEBUG1") return lDebug1; if (level == "DEBUG") return lDebug; if (level == "INFO") return lInfo; if (level == "WARNING") return lWarning; if (level == "ERROR") return lError; return lAny; }
PRInt32 nsXBLPrototypeHandler::GetMatchingKeyCode(const nsAString& aKeyName) { nsCAutoString keyName; keyName.AssignWithConversion(aKeyName); ToUpperCase(keyName); // We want case-insensitive comparison with data // stored as uppercase. PRUint32 keyNameLength = keyName.Length(); const char* keyNameStr = keyName.get(); for (PRUint16 i = 0; i < (sizeof(gKeyCodes) / sizeof(gKeyCodes[0])); ++i) if (keyNameLength == gKeyCodes[i].strlength && !nsCRT::strcmp(gKeyCodes[i].str, keyNameStr)) return gKeyCodes[i].keycode; return 0; }
BOOL vrResourceManager::LoadObjects( LPSTR strFileName ) { char buffer[255]; char dummy[255]; char read[255]; int iObjectCount = 0; memset( buffer, 0, 255 ); e_log.WriteOut("[STATUS] Parsing Resources from File %s \n", strFileName ); FILE *f = fopen( strFileName, "rt" ); if ( f == NULL ) return FALSE; while ( !feof(f) ) { while ( (strcmp( buffer, "<object>") != 0) && (strcmp( buffer, "<object>\n") != 0 ) ) { if ( feof( f ) ) return TRUE; fgets( (char*)buffer, 255, f ); } vrTriObject2 *o = new vrTriObject2(); if ( !o ) return FALSE; while ( strcmp( buffer, "</object>" ) != 0 )//читаем данные до конца тэга {//-------------------------------------------------------------- fgets( (char*)read, 255, f ); sscanf( read, "%s %s", buffer, dummy ); ToUpperCase( dummy ); if ( strcmp( buffer, "file" ) == 0 ) if ( !o->Load ( dummy ) ) return FALSE; if ( strcmp( buffer, "skin" ) == 0 ) if ( !o->LoadSkin ( dummy ) ) return FALSE; }//-------------------------------------------------------------- this->AddObject (o); iObjectCount++; } e_log.WriteOut("[STATUS] %i Objects Loaded \n", iObjectCount ); fclose(f); return TRUE; }
nsresult nsMimeXmlEmitter::WriteXMLTag(const char *tagName, const char *value) { if ( (!value) || (!*value) ) return NS_OK; char *upCaseTag = NULL; char *newValue = MsgEscapeHTML(value); if (!newValue) return NS_OK; nsCString newTagName(tagName); newTagName.StripWhitespace(); ToUpperCase(newTagName); upCaseTag = ToNewCString(newTagName); UtilityWrite("<header field=\""); UtilityWrite(upCaseTag); UtilityWrite("\">"); // Here is where we are going to try to L10N the tagName so we will always // get a field name next to an emitted header value. Note: Default will always // be the name of the header itself. // UtilityWrite("<headerdisplayname>"); char *l10nTagName = LocalizeHeaderName(upCaseTag, tagName); if ( (!l10nTagName) || (!*l10nTagName) ) UtilityWrite(tagName); else { UtilityWrite(l10nTagName); } PR_FREEIF(l10nTagName); UtilityWrite(": "); UtilityWrite("</headerdisplayname>"); // Now write out the actual value itself and move on! // UtilityWrite(newValue); UtilityWrite("</header>"); NS_Free(upCaseTag); PR_FREEIF(newValue); return NS_OK; }
PRUint32 uGlobalMenuItem::GetKeyCode(nsAString &aKeyName) { nsAutoCString keyName; CopyUTF16toUTF8(aKeyName, keyName); ToUpperCase(keyName); // We want case-insensitive comparison with data // stored as uppercase. PRUint32 keyNameLength = keyName.Length(); const char* keyNameStr = keyName.get(); for (PRUint16 i = 0; i < (sizeof(gKeyCodes) / sizeof(gKeyCodes[0])); ++i) if (keyNameLength == gKeyCodes[i].strlength && !strcmp(gKeyCodes[i].str, keyNameStr)) return gKeyCodes[i].keycode; return 0; }
/** * This method is called just after a "<!" has been consumed. * NOTE: Here we might consume DOCTYPE and "special" markups. * * @param aChar The last character read from the scanner. * @param aToken The OUT parameter that holds our resulting token. * @param aScanner Our source of data * @return Error result. */ nsresult nsHTMLTokenizer::ConsumeSpecialMarkup(PRUnichar aChar, CToken*& aToken, nsScanner& aScanner) { // Get the "!" aScanner.GetChar(aChar); nsresult result = NS_OK; nsAutoString theBufCopy; aScanner.Peek(theBufCopy, 20); ToUpperCase(theBufCopy); int32_t theIndex = theBufCopy.Find("DOCTYPE", false, 0, 0); nsTokenAllocator* theAllocator = this->GetTokenAllocator(); if (theIndex == kNotFound) { if ('[' == theBufCopy.CharAt(0)) { aToken = theAllocator->CreateTokenOfType(eToken_cdatasection, eHTMLTag_comment); } else if (StringBeginsWith(theBufCopy, NS_LITERAL_STRING("ELEMENT")) || StringBeginsWith(theBufCopy, NS_LITERAL_STRING("ATTLIST")) || StringBeginsWith(theBufCopy, NS_LITERAL_STRING("ENTITY")) || StringBeginsWith(theBufCopy, NS_LITERAL_STRING("NOTATION"))) { aToken = theAllocator->CreateTokenOfType(eToken_markupDecl, eHTMLTag_markupDecl); } else { aToken = theAllocator->CreateTokenOfType(eToken_comment, eHTMLTag_comment); } } else { aToken = theAllocator->CreateTokenOfType(eToken_doctypeDecl, eHTMLTag_doctypeDecl); } if (aToken) { result = aToken->Consume(aChar, aScanner, mFlags); AddToken(aToken, result, &mTokenDeque, theAllocator); } if (result == kNotAComment) { result = ConsumeText(aToken, aScanner); } return result; }
/** * JS property navigator.language, exposed to web content. * Take first value from Accept-Languages (HTTP header), which is * the "content language" freely set by the user in the Pref window. * * Do not use UI language (chosen app locale) here. * See RFC 2616, Section 15.1.4 "Privacy Issues Connected to Accept Headers" * * "en", "en-US" and "i-cherokee" and "" are valid. * Fallback in case of invalid pref should be "" (empty string), to * let site do fallback, e.g. to site's local language. */ NS_IMETHODIMP Navigator::GetLanguage(nsAString& aLanguage) { // E.g. "de-de, en-us,en". const nsAdoptingString& acceptLang = Preferences::GetLocalizedString("intl.accept_languages"); // Take everything before the first "," or ";", without trailing space. nsCharSeparatedTokenizer langTokenizer(acceptLang, ','); const nsSubstring &firstLangPart = langTokenizer.nextToken(); nsCharSeparatedTokenizer qTokenizer(firstLangPart, ';'); aLanguage.Assign(qTokenizer.nextToken()); // Checks and fixups: // replace "_" with "-" to avoid POSIX/Windows "en_US" notation. if (aLanguage.Length() > 2 && aLanguage[2] == PRUnichar('_')) { aLanguage.Replace(2, 1, PRUnichar('-')); // TODO replace all } // Use uppercase for country part, e.g. "en-US", not "en-us", see BCP47 // only uppercase 2-letter country codes, not "zh-Hant", "de-DE-x-goethe". if (aLanguage.Length() <= 2) { return NS_OK; } nsCharSeparatedTokenizer localeTokenizer(aLanguage, '-'); PRInt32 pos = 0; bool first = true; while (localeTokenizer.hasMoreTokens()) { const nsSubstring& code = localeTokenizer.nextToken(); if (code.Length() == 2 && !first) { nsAutoString upper(code); ToUpperCase(upper); aLanguage.Replace(pos, code.Length(), upper); } pos += code.Length() + 1; // 1 is the separator first = false; } return NS_OK; }