Bug 1621587 - remove external API compatibility functions from nsMsgUtils.h. r=benc DONTBUILD
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 16 Mar 2020 12:54:02 +0200
changeset 38496 2891d703d7591ad5492211961c7bfc1593ab8193
parent 38495 c84838d1d59664681b4abd35f5ee9f7c0dad6769
child 38497 3511b452ac30ac419fb0148b133a323939e3152f
push id400
push userclokep@gmail.com
push dateMon, 04 May 2020 18:56:09 +0000
reviewersbenc
bugs1621587
Bug 1621587 - remove external API compatibility functions from nsMsgUtils.h. r=benc DONTBUILD #define MsgLowerCaseEqualsLiteral(str, l) (str).LowerCaseEqualsLiteral(l) find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i -E "s/MsgLowerCaseEqualsLiteral\((.+), (.+)\)/\1.LowerCaseEqualsLiteral(\2)/g" {} \; sed -i -E "s/MsgLowerCaseEqualsLiteral\(([^,]+), */\1.LowerCaseEqualsLiteral(/g" mailnews/base/util/nsMsgDBFolder.cpp mailnews/compose/src/nsURLFetcher.cpp #define MsgRFindChar(str, ch, len) (str).RFindChar(ch, len) find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i -E "s/MsgRFindChar\(([^,]+), */\1.RFindChar(/g" {} \; #define MsgCompressWhitespace(str) (str).CompressWhitespace() find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i -E "s/MsgCompressWhitespace\(([^,]+)\)/\1.CompressWhitespace()/g" {} \; #define MsgReplaceSubstring(str, what, replacement) (str).ReplaceSubstring(what, replacement) find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i -E "s/MsgReplaceSubstring\(([^,]+), */\1.ReplaceSubstring(/g" {} \; #define MsgIsUTF8(str) mozilla::IsUtf8(str) find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i 's/MsgIsUTF8/mozilla::IsUtf8/g' {} \; #define MsgNewInterfaceRequestorAggregation(aFirst, aSecond, aResult) NS_NewInterfaceRequestorAggregation(aFirst, aSecond, aResult) find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i 's/MsgNewInterfaceRequestorAggregation/NS_NewInterfaceRequestorAggregation/g' {} \; #define MsgNewNotificationCallbacksAggregation(aCallbacks, aLoadGroup, aResult) NS_NewNotificationCallbacksAggregation(aCallbacks, aLoadGroup, aResult) find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i 's/MsgNewNotificationCallbacksAggregation/NS_NewNotificationCallbacksAggregation/g' {} \; #define MsgReplaceChar(aString, aNeedle, aReplacement) (aString).ReplaceChar(aNeedle, aReplacement) find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i -E "s/MsgReplaceChar\(([^,]+), */\1.ReplaceChar(/g" {} \; #define MsgFind(str, what, ignore_case, offset) (str).Find(what, ignore_case, offset) find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i -E "s/MsgFind\(([^,]+), */\1.Find(/g" {} \; #define MsgCountChar(aString, aChar) (aString).CountChar(aChar) find . -type f -not -path "*.hg/*" -regex ".*\.\(c\|h\|cpp\)$" -exec sed -i -E "s/MsgCountChar\(([^,]+), */\1.CountChar(/g" {} \; # Find files using mozilla:IsUTF8 but not including the header grep --exclude-dir=.hg -rl "mozilla::IsUtf8" | xargs grep -L "mozilla/Utf8.h" # Now remove defines from mailnews/base/util/nsMsgUtils.h manually # + remove IsUtf8 from nsMSgUtils.h cd .. ./mach clang-format -p comm/mailnews
mailnews/base/search/src/nsMsgSearchTerm.cpp
mailnews/base/src/nsMessenger.cpp
mailnews/base/src/nsMessengerWinIntegration.cpp
mailnews/base/src/nsMsgContentPolicy.cpp
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgTagService.cpp
mailnews/base/src/nsSpamSettings.cpp
mailnews/base/src/nsSubscribableServer.cpp
mailnews/base/util/nsMsgDBFolder.cpp
mailnews/base/util/nsMsgI18N.cpp
mailnews/base/util/nsMsgIncomingServer.cpp
mailnews/base/util/nsMsgUtils.cpp
mailnews/base/util/nsMsgUtils.h
mailnews/compose/src/nsMsgCompUtils.cpp
mailnews/compose/src/nsMsgCompose.cpp
mailnews/compose/src/nsMsgSend.cpp
mailnews/compose/src/nsSmtpProtocol.cpp
mailnews/compose/src/nsURLFetcher.cpp
mailnews/db/msgdb/src/nsMsgDatabase.cpp
mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
mailnews/imap/src/nsImapFlagAndUidState.cpp
mailnews/imap/src/nsImapIncomingServer.cpp
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/imap/src/nsImapService.cpp
mailnews/imap/src/nsImapUndoTxn.cpp
mailnews/imap/src/nsImapUrl.cpp
mailnews/imap/src/nsImapUtils.cpp
mailnews/import/outlook/src/MapiApi.cpp
mailnews/import/outlook/src/nsOutlookMail.cpp
mailnews/import/text/src/nsTextAddress.cpp
mailnews/local/src/nsLocalMailFolder.cpp
mailnews/local/src/nsLocalUndoTxn.cpp
mailnews/local/src/nsLocalUtils.cpp
mailnews/local/src/nsPop3Protocol.cpp
mailnews/mime/src/mimehdrs.cpp
mailnews/mime/src/nsStreamConverter.cpp
mailnews/news/src/nsNNTPProtocol.cpp
mailnews/news/src/nsNntpIncomingServer.cpp
mailnews/news/src/nsNntpService.cpp
--- a/mailnews/base/search/src/nsMsgSearchTerm.cpp
+++ b/mailnews/base/search/src/nsMsgSearchTerm.cpp
@@ -978,17 +978,17 @@ nsresult nsMsgSearchTerm::MatchString(co
     nsAutoString utf16StrToMatch;
     rv = NS_ERROR_UNEXPECTED;
     if (charset) {
       rv = nsMsgI18NConvertToUnicode(nsDependentCString(charset), stringToMatch,
                                      utf16StrToMatch);
     }
     if (NS_FAILED(rv)) {
       // No charset or conversion failed, maybe due to a bad charset, try UTF-8.
-      if (MsgIsUTF8(stringToMatch)) {
+      if (mozilla::IsUtf8(stringToMatch)) {
         CopyUTF8toUTF16(stringToMatch, utf16StrToMatch);
       } else {
         // Bad luck, let's assume ASCII/windows-1252 then.
         CopyASCIItoUTF16(stringToMatch, utf16StrToMatch);
       }
     }
 
     rv = MatchString(utf16StrToMatch, &result);
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -111,17 +111,17 @@ static void ConvertAndSanitizeFileName(c
   /* we need to convert the UTF-8 fileName to platform specific character set.
      The display name is in UTF-8 because it has been escaped from JS
   */
   MsgUnescapeString(displayName, 0, unescapedName);
   CopyUTF8toUTF16(unescapedName, aResult);
 
   // replace platform specific path separator and illegale characters to avoid
   // any confusion
-  MsgReplaceChar(aResult, FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '-');
+  aResult.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '-');
 }
 
 // ***************************************************
 // jefft - this is a rather obscured class serves for Save Message As File,
 // Save Message As Template, and Save Attachment to a file
 //
 class nsSaveAllAttachmentsState;
 
@@ -632,17 +632,17 @@ nsresult nsMessenger::SaveAttachment(nsI
   int32_t typeIndex = urlString.Find("?type=application/x-message-display");
   if (typeIndex != kNotFound) {
     urlString.Cut(typeIndex, sizeof("?type=application/x-message-display") - 1);
     // we also need to replace the next '&' with '?'
     int32_t firstPartIndex = urlString.FindChar('&');
     if (firstPartIndex != kNotFound) urlString.SetCharAt('?', firstPartIndex);
   }
 
-  MsgReplaceSubstring(urlString, "/;section", "?section");
+  urlString.ReplaceSubstring("/;section", "?section");
   nsCOMPtr<nsIURI> URL;
   nsresult rv = NS_NewURI(getter_AddRefs(URL), urlString);
 
   if (NS_SUCCEEDED(rv)) {
     rv = GetMessageServiceFromURI(aMessageUri, getter_AddRefs(messageService));
     if (NS_SUCCEEDED(rv)) {
       fetchService = do_QueryInterface(messageService);
       // if the message service has a fetch part service then we know we can
--- a/mailnews/base/src/nsMessengerWinIntegration.cpp
+++ b/mailnews/base/src/nsMessengerWinIntegration.cpp
@@ -590,28 +590,27 @@ nsMessengerWinIntegration::Observe(nsISu
 }
 
 static void EscapeAmpersands(nsString &aToolTip) {
   // First, check to see whether we have any ampersands.
   int32_t pos = aToolTip.FindChar('&');
   if (pos == kNotFound) return;
 
   // Next, see if we only have bare ampersands.
-  pos = MsgFind(aToolTip, "&&", false, pos);
+  pos = aToolTip.Find("&&", false, pos);
 
   // Windows tooltip code removes one ampersand from each run,
   // then collapses pairs of amperands. This means that in the easy case,
   // we need to replace each ampersand with three.
-  MsgReplaceSubstring(aToolTip, NS_LITERAL_STRING("&"),
-                      NS_LITERAL_STRING("&&&"));
+  aToolTip.ReplaceSubstring(NS_LITERAL_STRING("&"), NS_LITERAL_STRING("&&&"));
   if (pos == kNotFound) return;
 
   // We inserted too many ampersands. Remove some.
   for (;;) {
-    pos = MsgFind(aToolTip, "&&&&&&", false, pos);
+    pos = aToolTip.Find("&&&&&&", false, pos);
     if (pos == kNotFound) return;
 
     aToolTip.Cut(pos, 1);
     pos += 2;
   }
 }
 
 void nsMessengerWinIntegration::FillToolTipInfo() {
--- a/mailnews/base/src/nsMsgContentPolicy.cpp
+++ b/mailnews/base/src/nsMsgContentPolicy.cpp
@@ -434,19 +434,19 @@ bool nsMsgContentPolicy::IsExposedProtoc
   nsresult rv = aContentLocation->GetScheme(contentScheme);
   NS_ENSURE_SUCCESS(rv, false);
 
   // Check some exposed protocols. Not all protocols in the list of
   // network.protocol-handler.expose.* prefs in all-thunderbird.js are
   // admitted purely based on their scheme.
   // news, snews, nntp, imap and mailbox are checked before the call
   // to this function by matching content location and requesting location.
-  if (MsgLowerCaseEqualsLiteral(contentScheme, "mailto") ||
-      MsgLowerCaseEqualsLiteral(contentScheme, "addbook") ||
-      MsgLowerCaseEqualsLiteral(contentScheme, "about"))
+  if (contentScheme.LowerCaseEqualsLiteral("mailto") ||
+      contentScheme.LowerCaseEqualsLiteral("addbook") ||
+      contentScheme.LowerCaseEqualsLiteral("about"))
     return true;
 
   // check if customized exposed scheme
   if (mCustomExposedProtocols.Contains(contentScheme)) return true;
 
   bool isData;
   bool isChrome;
   bool isRes;
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -2149,25 +2149,25 @@ nsMsgDBView::Open(nsIMsgFolder *folder, 
     rv = folder->GetServer(getter_AddRefs(server));
     NS_ENSURE_SUCCESS(rv, rv);
     nsCString type;
     rv = server->GetType(type);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // I'm not sure this is correct, because XF virtual folders with mixed news
     // and mail can have this set.
-    mIsNews = MsgLowerCaseEqualsLiteral(type, "nntp");
+    mIsNews = type.LowerCaseEqualsLiteral("nntp");
 
     // Default to a virtual folder if folder not set, since synthetic search
     // views may not have a folder.
     uint32_t folderFlags = nsMsgFolderFlags::Virtual;
     if (folder) folder->GetFlags(&folderFlags);
 
     mIsXFVirtual = folderFlags & nsMsgFolderFlags::Virtual;
-    if (!mIsXFVirtual && MsgLowerCaseEqualsLiteral(type, "rss")) mIsRss = true;
+    if (!mIsXFVirtual && type.LowerCaseEqualsLiteral("rss")) mIsRss = true;
 
     // Special case nntp --> news since we'll break themes if we try to be
     // consistent.
     if (mIsNews)
       mMessageType.AssignLiteral("news");
     else
       CopyUTF8toUTF16(type, mMessageType);
 
@@ -7519,18 +7519,18 @@ bool nsMsgDBView::JunkControlsEnabled(ns
   if (folder) {
     // Check if this is a mail message in search folders.
     if (mIsXFVirtual) {
       nsCOMPtr<nsIMsgIncomingServer> server;
       folder->GetServer(getter_AddRefs(server));
       nsAutoCString type;
       if (server) server->GetType(type);
 
-      if (!(MsgLowerCaseEqualsLiteral(type, "nntp") ||
-            MsgLowerCaseEqualsLiteral(type, "rss")))
+      if (!(type.LowerCaseEqualsLiteral("nntp") ||
+            type.LowerCaseEqualsLiteral("rss")))
         return true;
     }
 
     // For rss and news, check the inherited folder property.
     nsAutoCString junkEnableOverride;
     folder->GetInheritedStringProperty("dobayes.mailnews@mozilla.org#junk",
                                        junkEnableOverride);
     if (junkEnableOverride.EqualsLiteral("true")) return true;
--- a/mailnews/base/src/nsMsgTagService.cpp
+++ b/mailnews/base/src/nsMsgTagService.cpp
@@ -205,17 +205,17 @@ NS_IMETHODIMP nsMsgTagService::AddTag(co
                                       const nsACString &color,
                                       const nsACString &ordinal) {
   // figure out key from tag. Apply transformation stripping out
   // illegal characters like <SP> and then convert to imap mod utf7.
   // Then, check if we have a tag with that key yet, and if so,
   // make it unique by appending A, AA, etc.
   // Should we use an iterator?
   nsAutoString transformedTag(tag);
-  MsgReplaceChar(transformedTag, " ()/{%*<>\\\"", '_');
+  transformedTag.ReplaceChar(" ()/{%*<>\\\"", '_');
   nsAutoCString key;
   CopyUTF16toMUTF7(transformedTag, key);
   // We have an imap server that converts keys to upper case so we're going
   // to normalize all keys to lower case (upper case looks ugly in prefs.js)
   ToLowerCase(key);
   nsAutoCString prefName(key);
   while (true) {
     nsAutoString tagValue;
--- a/mailnews/base/src/nsSpamSettings.cpp
+++ b/mailnews/base/src/nsSpamSettings.cpp
@@ -680,18 +680,18 @@ NS_IMETHODIMP nsSpamSettings::LogJunkStr
   PRExplodedTime exploded;
   PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &exploded);
 
   mozilla::DateTimeFormat::FormatPRExplodedTime(mozilla::kDateFormatShort,
                                                 mozilla::kTimeFormatSeconds,
                                                 &exploded, dateValue);
 
   nsCString timestampString(LOG_ENTRY_TIMESTAMP);
-  MsgReplaceSubstring(timestampString, "$S",
-                      NS_ConvertUTF16toUTF8(dateValue).get());
+  timestampString.ReplaceSubstring("$S",
+                                   NS_ConvertUTF16toUTF8(dateValue).get());
 
   nsCOMPtr<nsIOutputStream> logStream;
   rv = GetLogStream(getter_AddRefs(logStream));
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t writeCount;
 
   rv = logStream->Write(LOG_ENTRY_START_TAG, LOG_ENTRY_START_TAG_LEN,
--- a/mailnews/base/src/nsSubscribableServer.cpp
+++ b/mailnews/base/src/nsSubscribableServer.cpp
@@ -10,16 +10,17 @@
 #include "nsMsgI18N.h"
 #include "nsMsgUtils.h"
 #include "nsCOMArray.h"
 #include "nsArrayEnumerator.h"
 #include "nsStringEnumerator.h"
 #include "nsServiceManagerUtils.h"
 #include "nsTreeColumns.h"
 #include "mozilla/dom/DataTransfer.h"
+#include "mozilla/Utf8.h"
 
 nsSubscribableServer::nsSubscribableServer(void) {
   mDelimiter = '.';
   mShowFullName = true;
   mTreeRoot = nullptr;
   mStopped = false;
 }
 
@@ -109,17 +110,17 @@ nsSubscribableServer::AddTo(const nsACSt
 
 NS_IMETHODIMP
 nsSubscribableServer::SetState(const nsACString &aPath, bool aState,
                                bool *aStateChanged) {
   nsresult rv = NS_OK;
   NS_ASSERTION(!aPath.IsEmpty() && aStateChanged, "no path or stateChanged");
   if (aPath.IsEmpty() || !aStateChanged) return NS_ERROR_NULL_POINTER;
 
-  NS_ASSERTION(MsgIsUTF8(aPath), "aPath is not in UTF-8");
+  NS_ASSERTION(mozilla::IsUtf8(aPath), "aPath is not in UTF-8");
 
   *aStateChanged = false;
 
   SubscribeTreeNode *node = nullptr;
   rv = FindAndCreateNode(aPath, &node);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ASSERTION(node, "didn't find the node");
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -66,16 +66,17 @@
 #include "nsIMsgFilter.h"
 #include "nsIScriptError.h"
 #include "nsIURIMutator.h"
 #include "nsIXULAppInfo.h"
 #include "mozilla/Services.h"
 #include "mozilla/intl/LocaleService.h"
 #include "mozilla/Logging.h"
 #include "mozilla/UniquePtr.h"
+#include "mozilla/Utf8.h"
 
 using namespace mozilla;
 
 extern LazyLogModule FILTERLOGMODULE;
 
 static PRTime gtimeOfLastPurgeCheck;  // variable to know when to check for
                                       // purge threshold
 
@@ -2886,17 +2887,17 @@ nsresult nsMsgDBFolder::parseURI(bool ne
     // the name is the trailing directory in the path
     nsAutoCString fileName;
     nsAutoCString escapedFileName;
     url->GetFileName(escapedFileName);
     if (!escapedFileName.IsEmpty()) {
       // XXX conversion to unicode here? is fileName in UTF8?
       // yes, let's say it is in utf8
       MsgUnescapeString(escapedFileName, 0, fileName);
-      NS_ASSERTION(MsgIsUTF8(fileName), "fileName is not in UTF-8");
+      NS_ASSERTION(mozilla::IsUtf8(fileName), "fileName is not in UTF-8");
       CopyUTF8toUTF16(fileName, mName);
     }
   }
 
   // grab the server by parsing the URI and looking it up
   // in the account manager...
   // But avoid this extra work by first asking the parent, if any
   nsCOMPtr<nsIMsgIncomingServer> server = do_QueryReferent(mServer, &rv);
@@ -2960,17 +2961,17 @@ nsresult nsMsgDBFolder::parseURI(bool ne
     rv = server->GetLocalPath(getter_AddRefs(serverPath));
     if (NS_FAILED(rv)) return rv;
 
     if (!mPath && serverPath) {
       if (!newPath.IsEmpty()) {
         // I hope this is temporary - Ultimately,
         // NS_MsgCreatePathStringFromFolderURI will need to be fixed.
 #if defined(XP_WIN)
-        MsgReplaceChar(newPath, '/', '\\');
+        newPath.ReplaceChar('/', '\\');
 #endif
         rv = serverPath->AppendRelativeNativePath(newPath);
         NS_ASSERTION(NS_SUCCEEDED(rv), "failed to append to the serverPath");
         if (NS_FAILED(rv)) {
           mPath = nullptr;
           return rv;
         }
       }
@@ -3435,29 +3436,29 @@ NS_IMETHODIMP nsMsgDBFolder::AddSubfolde
   // have the right uri.
   // on disk, host\INBOX should be a folder with the uri
   // mailbox://user@host/Inbox" as mailbox://user@host/Inbox !=
   // mailbox://user@host/INBOX
   nsCOMPtr<nsIMsgFolder> rootFolder;
   rv = GetRootFolder(getter_AddRefs(rootFolder));
   if (NS_SUCCEEDED(rv) && rootFolder &&
       (rootFolder.get() == (nsIMsgFolder *)this)) {
-    if (MsgLowerCaseEqualsLiteral(escapedName, "inbox"))
+    if (escapedName.LowerCaseEqualsLiteral("inbox"))
       uri += "Inbox";
-    else if (MsgLowerCaseEqualsLiteral(escapedName, "unsent%20messages"))
+    else if (escapedName.LowerCaseEqualsLiteral("unsent%20messages"))
       uri += "Unsent%20Messages";
-    else if (MsgLowerCaseEqualsLiteral(escapedName, "drafts"))
+    else if (escapedName.LowerCaseEqualsLiteral("drafts"))
       uri += "Drafts";
-    else if (MsgLowerCaseEqualsLiteral(escapedName, "trash"))
+    else if (escapedName.LowerCaseEqualsLiteral("trash"))
       uri += "Trash";
-    else if (MsgLowerCaseEqualsLiteral(escapedName, "sent"))
+    else if (escapedName.LowerCaseEqualsLiteral("sent"))
       uri += "Sent";
-    else if (MsgLowerCaseEqualsLiteral(escapedName, "templates"))
+    else if (escapedName.LowerCaseEqualsLiteral("templates"))
       uri += "Templates";
-    else if (MsgLowerCaseEqualsLiteral(escapedName, "archives"))
+    else if (escapedName.LowerCaseEqualsLiteral("archives"))
       uri += "Archives";
     else
       uri += escapedName.get();
   } else
     uri += escapedName.get();
 
   nsCOMPtr<nsIMsgFolder> msgFolder;
   rv = GetChildWithURI(uri, false /*deep*/, true /*case Insensitive*/,
@@ -5158,23 +5159,22 @@ NS_IMETHODIMP nsMsgDBFolder::GetMsgTextF
  * @param aEncodingType  the encoding type (base64, quoted-printable)
  * @param aIsComplete    the snippet is actually the entire message so the
  *                       decoder doesn't have to worry about partial data
  * @param aMsgSnippet in/out argument. The encoded msg snippet and then the
  *                                     decoded snippet
  */
 void nsMsgDBFolder::decodeMsgSnippet(const nsACString &aEncodingType,
                                      bool aIsComplete, nsCString &aMsgSnippet) {
-  if (MsgLowerCaseEqualsLiteral(aEncodingType, ENCODING_BASE64)) {
+  if (aEncodingType.LowerCaseEqualsLiteral(ENCODING_BASE64)) {
     int32_t base64Len = aMsgSnippet.Length();
     if (aIsComplete) base64Len -= base64Len % 4;
     char *decodedBody = PL_Base64Decode(aMsgSnippet.get(), base64Len, nullptr);
     if (decodedBody) aMsgSnippet.Adopt(decodedBody);
-  } else if (MsgLowerCaseEqualsLiteral(aEncodingType,
-                                       ENCODING_QUOTED_PRINTABLE)) {
+  } else if (aEncodingType.LowerCaseEqualsLiteral(ENCODING_QUOTED_PRINTABLE)) {
     MsgStripQuotedPrintable(aMsgSnippet);
   }
 }
 
 /**
  * stripQuotesFromMsgSnippet - Reduces quoted reply text including the citation
  * (Scott wrote:) from the message snippet to " ... ". Assumes the snippet has
  * been decoded and converted to plain text.
@@ -5236,17 +5236,17 @@ nsresult nsMsgDBFolder::GetMsgPreviewTex
   nsCString msgBody;
   nsAutoCString charset;
   msgHdr->GetCharset(getter_Copies(charset));
   nsAutoCString contentType;
   nsresult rv = GetMsgTextFromStream(stream, charset, 4096, 255, true, true,
                                      contentType, msgBody);
   // replaces all tabs and line returns with a space,
   // then trims off leading and trailing white space
-  MsgCompressWhitespace(msgBody);
+  msgBody.CompressWhitespace();
   msgHdr->SetStringProperty("preview", msgBody.get());
   return rv;
 }
 
 void nsMsgDBFolder::UpdateTimestamps(bool allowUndo) {
   if (!(mFlags & (nsMsgFolderFlags::Trash | nsMsgFolderFlags::Junk))) {
     SetMRUTime();
     if (allowUndo)  // This is a proxy for a user-initiated act.
--- a/mailnews/base/util/nsMsgI18N.cpp
+++ b/mailnews/base/util/nsMsgI18N.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-// as does this
 #include "nsICharsetConverterManager.h"
 #include "mozilla/dom/FallbackEncoding.h"
+#include "mozilla/Utf8.h"
 #include "nsIServiceManager.h"
 
 #include "nsISupports.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsIMimeConverter.h"
 #include "nsMsgUtils.h"
 #include "nsMsgI18N.h"
@@ -322,17 +322,17 @@ nsresult nsMsgI18NShrinkUTF8Str(const ns
   if (inString.IsEmpty()) {
     outString.Truncate();
     return NS_OK;
   }
   if (inString.Length() < aMaxLength) {
     outString.Assign(inString);
     return NS_OK;
   }
-  NS_ASSERTION(MsgIsUTF8(inString), "Invalid UTF-8 string is inputted");
+  NS_ASSERTION(mozilla::IsUtf8(inString), "Invalid UTF-8 string is inputted");
   const char* start = inString.get();
   const char* end = start + inString.Length();
   const char* last = start + aMaxLength;
   const char* cur = start;
   const char* prev = nullptr;
   bool err = false;
   while (cur < last) {
     prev = cur;
@@ -345,17 +345,17 @@ nsresult nsMsgI18NShrinkUTF8Str(const ns
   uint32_t len = prev - start;
   outString.Assign(Substring(inString, 0, len));
   return NS_OK;
 }
 
 void nsMsgI18NConvertRawBytesToUTF16(const nsCString& inString,
                                      const nsACString& charset,
                                      nsAString& outString) {
-  if (MsgIsUTF8(inString)) {
+  if (mozilla::IsUtf8(inString)) {
     CopyUTF8toUTF16(inString, outString);
     return;
   }
 
   nsresult rv = nsMsgI18NConvertToUnicode(charset, inString, outString);
   if (NS_SUCCEEDED(rv)) return;
 
   const char* cur = inString.BeginReading();
@@ -368,17 +368,17 @@ void nsMsgI18NConvertRawBytesToUTF16(con
     else
       outString.Append(c);
   }
 }
 
 void nsMsgI18NConvertRawBytesToUTF8(const nsCString& inString,
                                     const nsACString& charset,
                                     nsACString& outString) {
-  if (MsgIsUTF8(inString)) {
+  if (mozilla::IsUtf8(inString)) {
     outString.Assign(inString);
     return;
   }
 
   nsAutoString utf16Text;
   nsresult rv = nsMsgI18NConvertToUnicode(charset, inString, utf16Text);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF16toUTF8(utf16Text, outString);
--- a/mailnews/base/util/nsMsgIncomingServer.cpp
+++ b/mailnews/base/util/nsMsgIncomingServer.cpp
@@ -1072,17 +1072,17 @@ nsMsgIncomingServer::GetEditableFilterLi
 }
 
 // If the hostname contains ':' (like hostname:1431)
 // then parse and set the port number.
 nsresult nsMsgIncomingServer::InternalSetHostName(const nsACString &aHostname,
                                                   const char *prefName) {
   nsCString hostname;
   hostname = aHostname;
-  if (MsgCountChar(hostname, ':') == 1) {
+  if (hostname.CountChar(':') == 1) {
     int32_t colonPos = hostname.FindChar(':');
     nsAutoCString portString(Substring(hostname, colonPos));
     hostname.SetLength(colonPos);
     nsresult err;
     int32_t port = portString.ToInteger(&err);
     if (NS_SUCCEEDED(err)) SetPort(port);
   }
   return SetCharValue(prefName, hostname);
@@ -1183,17 +1183,17 @@ nsMsgIncomingServer::SetRealHostName(con
     rv = OnUserOrHostNameChanged(oldName, aHostname, true);
   return rv;
 }
 
 NS_IMETHODIMP
 nsMsgIncomingServer::GetHostName(nsACString &aResult) {
   nsresult rv;
   rv = GetCharValue("hostname", aResult);
-  if (MsgCountChar(aResult, ':') == 1) {
+  if (aResult.CountChar(':') == 1) {
     // gack, we need to reformat the hostname - SetHostName will do that
     SetHostName(aResult);
     rv = GetCharValue("hostname", aResult);
   }
   return rv;
 }
 
 NS_IMETHODIMP
@@ -1201,17 +1201,17 @@ nsMsgIncomingServer::GetRealHostName(nsA
   // If 'realhostname' is set (was changed) then use it, otherwise use
   // 'hostname'
   nsresult rv;
   rv = GetCharValue("realhostname", aResult);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (aResult.IsEmpty()) return GetHostName(aResult);
 
-  if (MsgCountChar(aResult, ':') == 1) {
+  if (aResult.CountChar(':') == 1) {
     SetRealHostName(aResult);
     rv = GetCharValue("realhostname", aResult);
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
--- a/mailnews/base/util/nsMsgUtils.cpp
+++ b/mailnews/base/util/nsMsgUtils.cpp
@@ -77,16 +77,17 @@
 #include "nsIInputStream.h"
 #include "nsIChannel.h"
 #include "nsIURIMutator.h"
 #include "mozilla/Unused.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Encoding.h"
 #include "mozilla/EncodingDetector.h"
 #include "mozilla/UniquePtr.h"
+#include "mozilla/Utf8.h"
 
 /* for logging to Error Console */
 #include "nsIScriptError.h"
 #include "nsIConsoleService.h"
 
 // Log an error string to the error console
 // (adapted from nsContentUtils::LogSimpleConsoleError).
 // Flag can indicate error, warning or info.
@@ -471,17 +472,17 @@ nsresult FormatFileSize(int64_t size, bo
 
 nsresult NS_MsgCreatePathStringFromFolderURI(const char *aFolderURI,
                                              nsCString &aPathCString,
                                              const nsCString &aScheme,
                                              bool aIsNewsFolder) {
   // A file name has to be in native charset. Here we convert
   // to UTF-16 and check for 'unsafe' characters before converting
   // to native charset.
-  NS_ENSURE_TRUE(MsgIsUTF8(nsDependentCString(aFolderURI)),
+  NS_ENSURE_TRUE(mozilla::IsUtf8(nsDependentCString(aFolderURI)),
                  NS_ERROR_UNEXPECTED);
   NS_ConvertUTF8toUTF16 oldPath(aFolderURI);
 
   nsAutoString pathPiece, path;
 
   int32_t startSlashPos = oldPath.FindChar('/');
   int32_t endSlashPos = (startSlashPos >= 0)
                             ? oldPath.FindChar('/', startSlashPos + 1) - 1
--- a/mailnews/base/util/nsMsgUtils.h
+++ b/mailnews/base/util/nsMsgUtils.h
@@ -224,21 +224,16 @@ NS_MSG_BASE bool MsgHostDomainIsTrusted(
 
 // gets an nsIFile from a UTF-8 file:// path
 NS_MSG_BASE nsresult MsgGetLocalFileFromURI(const nsACString &aUTF8Path,
                                             nsIFile **aFile);
 
 NS_MSG_BASE void MsgStripQuotedPrintable(nsCString &aSrc);
 
 /*
- * Utility function copied from nsReadableUtils
- */
-NS_MSG_BASE bool MsgIsUTF8(const nsACString &aString);
-
-/*
  * Utility functions that call functions from nsINetUtil
  */
 
 NS_MSG_BASE nsresult MsgEscapeString(const nsACString &aStr, uint32_t aType,
                                      nsACString &aResult);
 
 NS_MSG_BASE nsresult MsgUnescapeString(const nsACString &aStr, uint32_t aFlags,
                                        nsACString &aResult);
@@ -335,37 +330,16 @@ NS_MSG_BASE nsresult MsgDetectCharsetFro
  */
 NS_MSG_BASE nsresult ConvertBufToPlainText(nsString &aConBuf, bool formatFlowed,
                                            bool delsp, bool formatOutput,
                                            bool disallowBreaks);
 
 #include "nsEscape.h"
 
 /**
- * The following methods are not exposed to the external API, but when we're
- * using the internal API we can simply redirect the calls appropriately.
- */
-#define MsgLowerCaseEqualsLiteral(str, l) (str).LowerCaseEqualsLiteral(l)
-#define MsgRFindChar(str, ch, len) (str).RFindChar(ch, len)
-#define MsgCompressWhitespace(str) (str).CompressWhitespace()
-#define MsgReplaceSubstring(str, what, replacement) \
-  (str).ReplaceSubstring(what, replacement)
-#define MsgIsUTF8(str) mozilla::IsUtf8(str)
-#define MsgNewInterfaceRequestorAggregation(aFirst, aSecond, aResult) \
-  NS_NewInterfaceRequestorAggregation(aFirst, aSecond, aResult)
-#define MsgNewNotificationCallbacksAggregation(aCallbacks, aLoadGroup, \
-                                               aResult)                \
-  NS_NewNotificationCallbacksAggregation(aCallbacks, aLoadGroup, aResult)
-#define MsgReplaceChar(aString, aNeedle, aReplacement) \
-  (aString).ReplaceChar(aNeedle, aReplacement)
-#define MsgFind(str, what, ignore_case, offset) \
-  (str).Find(what, ignore_case, offset)
-#define MsgCountChar(aString, aChar) (aString).CountChar(aChar)
-
-/**
  * Converts a hex string into an integer.
  * Processes up to aNumChars characters or the first non-hex char.
  * It is not an error if less than aNumChars valid hex digits are found.
  */
 NS_MSG_BASE uint64_t MsgUnhex(const char *aHexString, size_t aNumChars);
 
 /**
  * Checks if a string is a valid hex literal containing at least aNumChars
--- a/mailnews/compose/src/nsMsgCompUtils.cpp
+++ b/mailnews/compose/src/nsMsgCompUtils.cpp
@@ -1461,17 +1461,17 @@ void GetFolderURIFromUserPrefs(nsMsgDeli
         do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
     if (NS_FAILED(rv)) return;
     rv = prefs->GetCharPref("mail.default_sendlater_uri", uri);
     if (NS_FAILED(rv) || uri.IsEmpty())
       uri.AssignLiteral(ANY_SERVER);
     else {
       // check if uri is unescaped, and if so, escape it and reset the pef.
       if (uri.FindChar(' ') != kNotFound) {
-        MsgReplaceSubstring(uri, " ", "%20");
+        uri.ReplaceSubstring(" ", "%20");
         prefs->SetCharPref("mail.default_sendlater_uri", uri);
       }
     }
     return;
   }
 
   if (!identity) return;
 
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -65,16 +65,17 @@
 #include "mozilla/Services.h"
 #include "mozilla/mailnews/MimeHeaderParser.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/HTMLAnchorElement.h"
 #include "mozilla/dom/HTMLImageElement.h"
 #include "mozilla/dom/Selection.h"
+#include "mozilla/Utf8.h"
 #include "nsStreamConverter.h"
 #include "nsIObserverService.h"
 #include "nsIProtocolHandler.h"
 #include "nsContentUtils.h"
 #include "nsIFileURL.h"
 #include "nsTextNode.h"  // from dom/base
 #include "nsIParserUtils.h"
 
@@ -1380,17 +1381,17 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_
         int32_t index = userid.FindChar('@');
         if (index != kNotFound) userid.SetLength(index);
 
         if (userid.IsEmpty())
           attachment->SetName(NS_LITERAL_STRING("vcard.vcf"));
         else {
           // Replace any dot with underscore to stop vCards
           // generating false positives with some heuristic scanners
-          MsgReplaceChar(userid, '.', '_');
+          userid.ReplaceChar('.', '_');
           userid.AppendLiteral(".vcf");
           attachment->SetName(NS_ConvertASCIItoUTF16(userid));
         }
 
         attachment->SetUrl(vCardUrl);
         m_compFields->AddAttachment(attachment);
       }
     }
@@ -2047,17 +2048,17 @@ nsresult nsMsgCompose::CreateMessage(con
               sanitizedSubj.Assign(subject);
 
             // set the file size
             uint32_t messageSize;
             msgHdr->GetMessageSize(&messageSize);
             attachment->SetSize(messageSize);
 
             // change all '.' to '_'  see bug #271211
-            MsgReplaceChar(sanitizedSubj, ".", '_');
+            sanitizedSubj.ReplaceChar(".", '_');
             if (addExtension) sanitizedSubj.AppendLiteral(".eml");
             attachment->SetName(sanitizedSubj);
             attachment->SetUrl(nsDependentCString(uri));
             m_compFields->AddAttachment(attachment);
           }
 
           if (isFirstPass) {
             nsCString fwdPrefix;
@@ -3850,17 +3851,17 @@ nsresult nsMsgCompose::LoadDataFromFile(
   inputFile->Close();
 
   readSize = (uint32_t)fileSize;
 
   nsAutoCString sigEncoding(nsMsgI18NParseMetaCharset(file));
   bool removeSigCharset = !sigEncoding.IsEmpty() && m_composeHTML;
 
   if (sigEncoding.IsEmpty()) {
-    if (aAllowUTF8 && MsgIsUTF8(nsDependentCString(readBuf))) {
+    if (aAllowUTF8 && mozilla::IsUtf8(nsDependentCString(readBuf))) {
       sigEncoding.AssignLiteral("UTF-8");
     } else if (sigEncoding.IsEmpty() && aAllowUTF16 && readSize % 2 == 0 &&
                readSize >= 2 &&
                ((readBuf[0] == char(0xFE) && readBuf[1] == char(0xFF)) ||
                 (readBuf[0] == char(0xFF) && readBuf[1] == char(0xFE)))) {
       sigEncoding.AssignLiteral("UTF-16");
     } else {
       // default to platform encoding for plain text files w/o meta charset
@@ -4289,18 +4290,17 @@ nsresult nsMsgCompose::BuildBodyMessageA
   nsAutoString tSignature;
   if (addSignature) ProcessSignature(m_identity, isQuoted, &tSignature);
 
   // if type is new, but we have body, this is probably a mapi send, so we need
   // to replace '\n' with <br> so that the line breaks won't be lost by html. if
   // mailtourl, do the same.
   if (m_composeHTML &&
       (mType == nsIMsgCompType::New || mType == nsIMsgCompType::MailToUrl))
-    MsgReplaceSubstring(body, NS_LITERAL_STRING("\n"),
-                        NS_LITERAL_STRING("<br>"));
+    body.ReplaceSubstring(NS_LITERAL_STRING("\n"), NS_LITERAL_STRING("<br>"));
 
   // Restore flowed text wrapping for Drafts/Templates.
   // Look for unquoted lines - if we have an unquoted line
   // that ends in a space, join this line with the next one
   // by removing the end of line char(s).
   int32_t wrapping_enabled = 0;
   GetWrapLength(&wrapping_enabled);
   if (!m_composeHTML && wrapping_enabled) {
@@ -4382,17 +4382,17 @@ nsresult nsMsgCompose::NotifyStateListen
   return NS_OK;
 }
 
 nsresult nsMsgCompose::AttachmentPrettyName(const nsACString &scheme,
                                             const char *charset,
                                             nsACString &_retval) {
   nsresult rv;
 
-  if (MsgLowerCaseEqualsLiteral(StringHead(scheme, 5), "file:")) {
+  if (StringHead(scheme, 5).LowerCaseEqualsLiteral("file:")) {
     nsCOMPtr<nsIFile> file;
     rv = NS_GetFileFromURLSpec(scheme, getter_AddRefs(file));
     NS_ENSURE_SUCCESS(rv, rv);
     nsAutoString leafName;
     rv = file->GetLeafName(leafName);
     NS_ENSURE_SUCCESS(rv, rv);
     CopyUTF16toUTF8(leafName, _retval);
     return rv;
@@ -4408,18 +4408,17 @@ nsresult nsMsgCompose::AttachmentPrettyN
   nsAutoString retUrl;
   rv = textToSubURI->UnEscapeURIForUI(nsDependentCString(cset), scheme, retUrl);
 
   if (NS_SUCCEEDED(rv)) {
     CopyUTF16toUTF8(retUrl, _retval);
   } else {
     _retval.Assign(scheme);
   }
-  if (MsgLowerCaseEqualsLiteral(StringHead(scheme, 5), "http:"))
-    _retval.Cut(0, 7);
+  if (StringHead(scheme, 5).LowerCaseEqualsLiteral("http:")) _retval.Cut(0, 7);
 
   return NS_OK;
 }
 
 /**
  * Retrieve address book directories and mailing lists.
  *
  * @param aDirUri               directory URI
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -336,17 +336,17 @@ nsresult nsMsgComposeAndSend::GetNotific
   if (msgWindow) {
     nsCOMPtr<nsIDocShell> docShell;
     msgWindow->GetRootDocShell(getter_AddRefs(docShell));
     nsCOMPtr<nsIInterfaceRequestor> ir(do_QueryInterface(docShell));
     nsCOMPtr<nsIInterfaceRequestor> notificationCallbacks;
     msgWindow->GetNotificationCallbacks(getter_AddRefs(notificationCallbacks));
     if (notificationCallbacks) {
       nsCOMPtr<nsIInterfaceRequestor> aggregrateIR;
-      MsgNewInterfaceRequestorAggregation(notificationCallbacks, ir,
+      NS_NewInterfaceRequestorAggregation(notificationCallbacks, ir,
                                           getter_AddRefs(aggregrateIR));
       ir = aggregrateIR;
     }
     if (ir) {
       ir.forget(aCallbacks);
       return NS_OK;
     }
   }
@@ -1837,18 +1837,18 @@ nsresult nsMsgComposeAndSend::AddCompFie
                       if (!type.EqualsLiteral(
                               "multipart/appledouble"))  // can't do apple
                                                          // double on non-macs
 #endif
                         m_attachments[newLoc]->m_type = type;
                       // rtf and vcs files may look like text to sniffers,
                       // but they're not human readable.
                       if (type.IsEmpty() && !fileExt.IsEmpty() &&
-                          (MsgLowerCaseEqualsLiteral(fileExt, "rtf") ||
-                           MsgLowerCaseEqualsLiteral(fileExt, "vcs")))
+                          (fileExt.LowerCaseEqualsLiteral("rtf") ||
+                           fileExt.LowerCaseEqualsLiteral("vcs")))
                         m_attachments[newLoc]->m_type =
                             APPLICATION_OCTET_STREAM;
                     }
                   }
                 }
               }
             }
           } else {
@@ -2369,17 +2369,17 @@ nsresult nsMsgComposeAndSend::InitCompos
           }
         }
       }
 
       if (useDefaultFCC) {
         nsCString uri;
         GetFolderURIFromUserPrefs(nsMsgDeliverNow, mUserIdentity, uri);
         mCompFields->SetFcc(
-            MsgLowerCaseEqualsLiteral(uri, "nocopy://") ? "" : uri.get());
+            uri.LowerCaseEqualsLiteral("nocopy://") ? "" : uri.get());
       }
     }
   }
 
   //
   // Deal with an additional FCC operation for this email.
   //
   const char *fieldsFCC2 = fields->GetFcc2();
--- a/mailnews/compose/src/nsSmtpProtocol.cpp
+++ b/mailnews/compose/src/nsSmtpProtocol.cpp
@@ -847,17 +847,17 @@ nsresult nsSmtpProtocol::SendEhloRespons
   int32_t endPos;
   do {
     endPos = m_responseText.FindChar('\n', startPos + 1);
     nsAutoCString responseLine;
     responseLine.Assign(
         Substring(m_responseText, startPos,
                   (endPos >= 0 ? endPos : responseLength) - startPos));
 
-    MsgCompressWhitespace(responseLine);
+    responseLine.CompressWhitespace();
     if (responseLine.LowerCaseEqualsLiteral("starttls")) {
       SetFlag(SMTP_EHLO_STARTTLS_ENABLED);
     } else if (responseLine.LowerCaseEqualsLiteral("dsn")) {
       SetFlag(SMTP_EHLO_DSN_ENABLED);
     } else if (responseLine.LowerCaseEqualsLiteral("clientid")) {
       SetFlag(SMTP_EHLO_CLIENTID_ENABLED);
       // If we have "clientid" in the ehlo response, then TLS must be present.
       if (m_prefSocketType == nsMsgSocketType::SSL) m_tlsEnabled = true;
--- a/mailnews/compose/src/nsURLFetcher.cpp
+++ b/mailnews/compose/src/nsURLFetcher.cpp
@@ -227,18 +227,17 @@ nsURLFetcher::OnStopRequest(nsIRequest *
 
   // time to close the output stream...
   if (mOutStream) {
     mOutStream->Close();
     mOutStream = nullptr;
 
     /* In case of multipart/x-mixed-replace, we need to truncate the file to the
      * current part size */
-    if (MsgLowerCaseEqualsLiteral(mConverterContentType,
-                                  MULTIPART_MIXED_REPLACE)) {
+    if (mConverterContentType.LowerCaseEqualsLiteral(MULTIPART_MIXED_REPLACE)) {
       mLocalFile->SetFileSize(mTotalWritten);
     }
   }
 
   // Now if there is a callback, we need to call it...
   if (mCallback)
     mCallback(aStatus, mContentType, mCharset, mTotalWritten, nullptr,
               mTagData);
@@ -378,18 +377,18 @@ nsURLFetcherStreamConsumer::~nsURLFetche
 /** nsIRequestObserver methods **/
 
 /* void onStartRequest (in nsIRequest request); */
 NS_IMETHODIMP nsURLFetcherStreamConsumer::OnStartRequest(nsIRequest *aRequest) {
   if (!mURLFetcher || !mURLFetcher->mOutStream) return NS_ERROR_FAILURE;
 
   /* In case of multipart/x-mixed-replace, we need to erase the output file
    * content */
-  if (MsgLowerCaseEqualsLiteral(mURLFetcher->mConverterContentType,
-                                MULTIPART_MIXED_REPLACE)) {
+  if (mURLFetcher->mConverterContentType.LowerCaseEqualsLiteral(
+          MULTIPART_MIXED_REPLACE)) {
     nsCOMPtr<nsISeekableStream> seekStream =
         do_QueryInterface(mURLFetcher->mOutStream);
     if (seekStream) seekStream->Seek(nsISeekableStream::NS_SEEK_SET, 0);
     mURLFetcher->mTotalWritten = 0;
   }
 
   return NS_OK;
 }
--- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp
+++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp
@@ -934,17 +934,17 @@ class MsgDBReporter final : public nsIMe
     nsCOMPtr<nsIMsgFolder> folder;
     mDatabase->GetFolder(getter_AddRefs(folder));
     if (folder) {
       if (aAnonymize)
         memoryPath.AppendLiteral("<anonymized>");
       else {
         nsAutoCString folderURL;
         folder->GetFolderURL(folderURL);
-        MsgReplaceChar(folderURL, '/', '\\');
+        folderURL.ReplaceChar('/', '\\');
         memoryPath += folderURL;
       }
     } else {
       memoryPath.AppendLiteral("UNKNOWN-FOLDER");
     }
     memoryPath.Append(')');
   }
 
--- a/mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
+++ b/mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
@@ -737,20 +737,20 @@ void Tokenizer::tokenize(const char* aTe
 
   // RSS feeds store their summary information as an iframe. But due to
   // bug 365953, we can't see those in the plaintext serializer. As a
   // workaround, allow an option to replace iframe with div in the message
   // text. We disable by default, since most people won't be applying bayes
   // to RSS
 
   if (mIframeToDiv) {
-    MsgReplaceSubstring(text, NS_LITERAL_STRING("<iframe"),
-                        NS_LITERAL_STRING("<div"));
-    MsgReplaceSubstring(text, NS_LITERAL_STRING("/iframe>"),
-                        NS_LITERAL_STRING("/div>"));
+    text.ReplaceSubstring(NS_LITERAL_STRING("<iframe"),
+                          NS_LITERAL_STRING("<div"));
+    text.ReplaceSubstring(NS_LITERAL_STRING("/iframe>"),
+                          NS_LITERAL_STRING("/div>"));
   }
 
   stripHTML(text, strippedUCS2);
 
   // convert 0x3000(full width space) into 0x0020
   char16_t* substr_start = strippedUCS2.BeginWriting();
   char16_t* substr_end = strippedUCS2.EndWriting();
   while (substr_start != substr_end) {
--- a/mailnews/imap/src/nsImapFlagAndUidState.cpp
+++ b/mailnews/imap/src/nsImapFlagAndUidState.cpp
@@ -236,18 +236,18 @@ NS_IMETHODIMP nsImapFlagAndUidState::Add
       // and the flag is at the beginning of the string or there is ' ' + flag
       // then we have this flag already;
       if (((oldValue.Length() == existingCustomFlagPos + customFlagLen) ||
            (oldValue.CharAt(existingCustomFlagPos + customFlagLen) == ' ')) &&
           ((existingCustomFlagPos == 0) ||
            (oldValue.CharAt(existingCustomFlagPos - 1) == ' ')))
         return NS_OK;
       // else, advance to next flag
-      existingCustomFlagPos = MsgFind(oldValue, customFlagString, false,
-                                      existingCustomFlagPos + customFlagLen);
+      existingCustomFlagPos = oldValue.Find(
+          customFlagString, false, existingCustomFlagPos + customFlagLen);
     }
     ourCustomFlags.Assign(oldValue);
     ourCustomFlags.Append(' ');
     ourCustomFlags.Append(customFlag);
     m_customFlagsHash.Remove(uid);
   } else {
     ourCustomFlags.Assign(customFlag);
   }
--- a/mailnews/imap/src/nsImapIncomingServer.cpp
+++ b/mailnews/imap/src/nsImapIncomingServer.cpp
@@ -36,16 +36,17 @@
 #include "nsIMAPNamespace.h"
 #include "nsArrayUtils.h"
 #include "nsMsgUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCRTGlue.h"
 #include "mozilla/Services.h"
 #include "nsNetUtil.h"
+#include "mozilla/Utf8.h"
 
 using namespace mozilla;
 
 // Despite its name, this contains a folder path, for example INBOX/Trash.
 #define PREF_TRASH_FOLDER_PATH "trash_folder_name"
 #define DEFAULT_TRASH_FOLDER_PATH "Trash"  // XXX Is this a useful default?
 
 static NS_DEFINE_CID(kImapProtocolCID, NS_IMAPPROTOCOL_CID);
@@ -1026,55 +1027,55 @@ NS_IMETHODIMP nsImapIncomingServer::Poss
     // If there is a hierarchy, there is a parent.
     // Don't strip off slash if it's the first character
     parentName.SetLength(leafPos);
     folderName.Cut(0, leafPos + 1);  // get rid of the parent name
     haveParent = true;
     parentUri.Append('/');
     parentUri.Append(parentName);
   }
-  if (MsgLowerCaseEqualsLiteral(folderPath, "inbox") &&
+  if (folderPath.LowerCaseEqualsLiteral("inbox") &&
       hierarchyDelimiter == kOnlineHierarchySeparatorNil) {
     hierarchyDelimiter = '/';  // set to default in this case (as in 4.x)
     hostFolder->SetHierarchyDelimiter(hierarchyDelimiter);
   }
 
   nsCOMPtr<nsIMsgFolder> child;
 
   // nsCString possibleName(aSpec->allocatedPathName);
   uri.Append('/');
   uri.Append(dupFolderPath);
-  bool caseInsensitive = MsgLowerCaseEqualsLiteral(dupFolderPath, "inbox");
+  bool caseInsensitive = dupFolderPath.LowerCaseEqualsLiteral("inbox");
   a_nsIFolder->GetChildWithURI(uri, true, caseInsensitive,
                                getter_AddRefs(child));
   // if we couldn't find this folder by URI, tell the imap code it's a new
   // folder to us
   *aNewFolder = !child;
   if (child) found = true;
   if (!found) {
     // trying to find/discover the parent
     if (haveParent) {
       nsCOMPtr<nsIMsgFolder> parent;
       bool parentIsNew;
-      caseInsensitive = MsgLowerCaseEqualsLiteral(parentName, "inbox");
+      caseInsensitive = parentName.LowerCaseEqualsLiteral("inbox");
       a_nsIFolder->GetChildWithURI(parentUri, true, caseInsensitive,
                                    getter_AddRefs(parent));
       if (!parent /* || parentFolder->GetFolderNeedsAdded()*/) {
         PossibleImapMailbox(
             parentName, hierarchyDelimiter,
             kNoselect |       // be defensive
                 ((boxFlags &  // only inherit certain flags from the child
                   (kPublicMailbox | kOtherUsersMailbox | kPersonalMailbox))),
             &parentIsNew);
       }
     }
     rv = hostFolder->CreateClientSubfolderInfo(
         dupFolderPath, hierarchyDelimiter, boxFlags, false);
     NS_ENSURE_SUCCESS(rv, rv);
-    caseInsensitive = MsgLowerCaseEqualsLiteral(dupFolderPath, "inbox");
+    caseInsensitive = dupFolderPath.LowerCaseEqualsLiteral("inbox");
     a_nsIFolder->GetChildWithURI(uri, true, caseInsensitive,
                                  getter_AddRefs(child));
   }
   if (child) {
     nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(child);
     if (imapFolder) {
       nsAutoCString onlineName;
       nsAutoString unicodeName;
@@ -1088,17 +1089,17 @@ NS_IMETHODIMP nsImapIncomingServer::Poss
       }
 
       imapFolder->SetBoxFlags(boxFlags);
       imapFolder->SetExplicitlyVerify(explicitlyVerify);
       imapFolder->GetOnlineName(onlineName);
 
       // online name needs to use the correct hierarchy delimiter (I think...)
       // or the canonical path - one or the other, but be consistent.
-      MsgReplaceChar(dupFolderPath, '/', hierarchyDelimiter);
+      dupFolderPath.ReplaceChar('/', hierarchyDelimiter);
       if (hierarchyDelimiter != '/')
         nsImapUrl::UnescapeSlashes(dupFolderPath.BeginWriting());
 
       // GMail gives us a localized name for the inbox but doesn't let
       // us select that localized name.
       if (boxFlags & kImapInbox)
         imapFolder->SetOnlineName(NS_LITERAL_CSTRING("INBOX"));
       else if (onlineName.IsEmpty() || !onlineName.Equals(dupFolderPath))
@@ -2266,17 +2267,17 @@ NS_IMETHODIMP
 nsImapIncomingServer::AddTo(const nsACString &aName, bool addAsSubscribed,
                             bool aSubscribable, bool changeIfExists) {
   nsresult rv = EnsureInner();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // RFC 3501 allows UTF-8 in addition to modified UTF-7
   // If it's not UTF-8, it cannot be MUTF7, either. We just ignore it.
   // (otherwise we'll crash. see #63186)
-  if (!MsgIsUTF8(aName)) return NS_OK;
+  if (!mozilla::IsUtf8(aName)) return NS_OK;
 
   if (!NS_IsAscii(aName.BeginReading(), aName.Length())) {
     nsAutoCString name;
     CopyUTF16toMUTF7(NS_ConvertUTF8toUTF16(aName), name);
     return mInner->AddTo(name, addAsSubscribed, aSubscribable, changeIfExists);
   }
   return mInner->AddTo(aName, addAsSubscribed, aSubscribable, changeIfExists);
 }
@@ -2918,26 +2919,26 @@ nsImapIncomingServer::GetUriWithNamespac
       rv = GetServerDirectory(onlineDir);
       NS_ENSURE_SUCCESS(rv, rv);
       if (!onlineDir.IsEmpty()) {
         char delimiter = ns->GetDelimiter();
         if (onlineDir.Last() != delimiter) onlineDir += delimiter;
         if (onlineDir.Equals(namespacePrefix)) return NS_OK;
       }
 
-      MsgReplaceChar(namespacePrefix, ns->GetDelimiter(),
-                     '/');  // use canonical format
+      namespacePrefix.ReplaceChar(ns->GetDelimiter(),
+                                  '/');  // use canonical format
       nsCString uri(originalUri);
       int32_t index = uri.Find("//");        // find scheme
       index = uri.FindChar('/', index + 2);  // find '/' after scheme
       // it may be the case that this is the INBOX uri, in which case
       // we don't want to prepend the namespace. In that case, the uri ends with
       // "INBOX", but the namespace is "INBOX/", so they don't match.
-      if (MsgFind(uri, namespacePrefix, false, index + 1) != index + 1 &&
-          !MsgLowerCaseEqualsLiteral(Substring(uri, index + 1), "inbox"))
+      if (uri.Find(namespacePrefix, false, index + 1) != index + 1 &&
+          !Substring(uri, index + 1).LowerCaseEqualsLiteral("inbox"))
         uri.Insert(namespacePrefix, index + 1);  // insert namespace prefix
       convertedUri = uri;
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP nsImapIncomingServer::GetTrashFolderName(nsAString &retval) {
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -1870,17 +1870,17 @@ nsImapMailFolder::GetDBFolderInfoAndDB(n
       nsCString hostname;
       rv = GetHostname(hostname);
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsCString onlineCName;
       rv = nsImapURI2FullName(kImapRootURI, hostname.get(), uri.get(),
                               getter_Copies(onlineCName));
       if (m_hierarchyDelimiter != '/')
-        MsgReplaceChar(onlineCName, '/', m_hierarchyDelimiter);
+        onlineCName.ReplaceChar('/', m_hierarchyDelimiter);
       m_onlineFolderName.Assign(onlineCName);
       CopyASCIItoUTF16(onlineCName, autoOnlineName);
     }
     (*folderInfo)->SetProperty("onlineName", autoOnlineName);
   }
   return rv;
 }
 
@@ -8885,17 +8885,17 @@ NS_IMETHODIMP nsImapMailFolder::GetOffli
           if (labelNames[i].EqualsLiteral("\"\\\\Spam\""))
             rv = rootFolder->GetFolderWithFlags(nsMsgFolderFlags::Junk,
                                                 getter_AddRefs(subMsgFolder));
           if (labelNames[i].EqualsLiteral("\"\\\\Sent\""))
             rv = rootFolder->GetFolderWithFlags(nsMsgFolderFlags::SentMail,
                                                 getter_AddRefs(subMsgFolder));
           if (labelNames[i].Find("[Imap]/", /* ignoreCase = */ true) !=
               kNotFound) {
-            MsgReplaceSubstring(labelNames[i], "[Imap]/", "");
+            labelNames[i].ReplaceSubstring("[Imap]/", "");
             imapRootFolder->FindOnlineSubFolder(labelNames[i],
                                                 getter_AddRefs(subFolder));
             subMsgFolder = do_QueryInterface(subFolder);
           }
           if (!subMsgFolder) {
             imapRootFolder->FindOnlineSubFolder(labelNames[i],
                                                 getter_AddRefs(subFolder));
             subMsgFolder = do_QueryInterface(subFolder);
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -725,17 +725,17 @@ static void SetSecurityCallbacksFromChan
                                             nsIChannel *aChannel) {
   nsCOMPtr<nsIInterfaceRequestor> callbacks;
   aChannel->GetNotificationCallbacks(getter_AddRefs(callbacks));
 
   nsCOMPtr<nsILoadGroup> loadGroup;
   aChannel->GetLoadGroup(getter_AddRefs(loadGroup));
 
   nsCOMPtr<nsIInterfaceRequestor> securityCallbacks;
-  MsgNewNotificationCallbacksAggregation(callbacks, loadGroup,
+  NS_NewNotificationCallbacksAggregation(callbacks, loadGroup,
                                          getter_AddRefs(securityCallbacks));
   if (securityCallbacks) aTrans->SetSecurityCallbacks(securityCallbacks);
 }
 
 // Setup With Url is intended to set up data which is held on a PER URL basis
 // and not a per connection basis. If you have data which is independent of the
 // url we are currently running, then you should put it in Initialize(). This is
 // only ever called from the UI thread. It is called from LoadUrl, right before
@@ -825,17 +825,17 @@ nsresult nsImapProtocol::SetupWithUrl(ns
         // the messageWindow, with fallback to the docShell (and the
         // loadgroup).
         nsCOMPtr<nsIDocShell> docShell;
         msgWindow->GetMessageWindowDocShell(getter_AddRefs(docShell));
         nsCOMPtr<nsIInterfaceRequestor> ir(do_QueryInterface(docShell));
         nsCOMPtr<nsIInterfaceRequestor> interfaceRequestor;
         msgWindow->GetNotificationCallbacks(getter_AddRefs(interfaceRequestor));
         nsCOMPtr<nsIInterfaceRequestor> aggregateIR;
-        MsgNewInterfaceRequestorAggregation(interfaceRequestor, ir,
+        NS_NewInterfaceRequestorAggregation(interfaceRequestor, ir,
                                             getter_AddRefs(aggregateIR));
         m_mockChannel->SetNotificationCallbacks(aggregateIR);
       }
     }
 
     // since we'll be making calls directly from the imap thread to the channel
     // listener, we need to turn it into a proxy object....we'll assume that the
     // listener is on the same thread as the event sink queue
@@ -4478,17 +4478,17 @@ void nsImapProtocol::Log(const char *log
     int32_t lastLineEnd;
 
     // nspr line length is 512, and we allow some space for the log preamble.
     const int kLogDataChunkSize = 400;
 
     // break up buffers > 400 bytes on line boundaries.
     if (logDataLen > kLogDataChunkSize) {
       logDataLines.Assign(logData);
-      lastLineEnd = MsgRFindChar(logDataLines, '\n', kLogDataChunkSize);
+      lastLineEnd = logDataLines.RFindChar('\n', kLogDataChunkSize);
       // null terminate the last line
       if (lastLineEnd == kNotFound) lastLineEnd = kLogDataChunkSize - 1;
 
       logDataLines.Insert('\0', lastLineEnd + 1);
       logDataToLog = logDataLines.get();
     } else {
       logDataToLog = logData;
       lastLineEnd = logDataLen;
@@ -4527,17 +4527,17 @@ void nsImapProtocol::Log(const char *log
 
     // dump the rest of the string in < 400 byte chunks
     while (logDataLen > kLogDataChunkSize) {
       logDataLines.Cut(
           0,
           lastLineEnd + 2);  // + 2 to account for the LF and the '\0' we added
       logDataLen = logDataLines.Length();
       lastLineEnd = (logDataLen > kLogDataChunkSize)
-                        ? MsgRFindChar(logDataLines, '\n', kLogDataChunkSize)
+                        ? logDataLines.RFindChar('\n', kLogDataChunkSize)
                         : kNotFound;
       // null terminate the last line
       if (lastLineEnd == kNotFound) lastLineEnd = kLogDataChunkSize - 1;
       logDataLines.Insert('\0', lastLineEnd + 1);
       logDataToLog = logDataLines.get();
       MOZ_LOG(IMAP, LogLevel::Info, ("%.400s", logDataToLog));
     }
   }
--- a/mailnews/imap/src/nsImapService.cpp
+++ b/mailnews/imap/src/nsImapService.cpp
@@ -265,17 +265,17 @@ NS_IMETHODIMP nsImapService::OpenAttachm
     const char *aMessageUri, nsISupports *aDisplayConsumer,
     nsIMsgWindow *aMsgWindow, nsIUrlListener *aUrlListener) {
   // okay this is a little tricky....we may have to fetch the mime part
   // or it may already be downloaded for us....the only way i can tell to
   // distinguish the two events is to search for ?section or ?part
 
   nsAutoCString uri(aMessageUri);
   nsAutoCString urlString(aUrl);
-  MsgReplaceSubstring(urlString, "/;section", "?section");
+  urlString.ReplaceSubstring("/;section", "?section");
 
   // more stuff i don't understand
   int32_t sectionPos = urlString.Find("?section");
   // if we have a section field then we must be dealing with a mime part we need
   // to fetchf
   if (sectionPos > 0) {
     uri.Append(Substring(urlString, sectionPos));
     uri += "&type=";
@@ -481,18 +481,18 @@ NS_IMETHODIMP nsImapService::DisplayMess
         if (NS_SUCCEEDED(rv) && aImapServer)
           aImapServer->GetMimePartsOnDemand(&useMimePartsOnDemand);
       }
 
       nsAutoCString uriStr(aMessageURI);
       int32_t keySeparator = uriStr.RFindChar('#');
       if (keySeparator != -1) {
         int32_t keyEndSeparator = MsgFindCharInSet(uriStr, "/?&", keySeparator);
-        int32_t mpodFetchPos = MsgFind(uriStr, "fetchCompleteMessage=true",
-                                       false, keyEndSeparator);
+        int32_t mpodFetchPos =
+            uriStr.Find("fetchCompleteMessage=true", false, keyEndSeparator);
         if (mpodFetchPos != -1) useMimePartsOnDemand = false;
       }
 
       if (folder) {
         folder->ShouldStoreMsgOffline(key, &shouldStoreMsgOffline);
         folder->HasMsgOffline(key, &hasMsgOffline);
       }
       imapUrl->SetStoreResultsOffline(shouldStoreMsgOffline);
--- a/mailnews/imap/src/nsImapUndoTxn.cpp
+++ b/mailnews/imap/src/nsImapUndoTxn.cpp
@@ -43,17 +43,17 @@ nsresult nsImapMoveCopyMsgTxn::Init(nsIM
   nsCOMPtr<nsIMsgDBHdr> srcHdr;
   nsCOMPtr<nsIMsgDBHdr> copySrcHdr;
   nsCString messageId;
 
   for (i = 0; i < count; i++) {
     rv = srcDB->GetMsgHdrForKey(m_srcKeyArray[i], getter_AddRefs(srcHdr));
     if (NS_SUCCEEDED(rv)) {
       // ** jt -- only do this for mailbox protocol
-      if (MsgLowerCaseEqualsLiteral(protocolType, "mailbox")) {
+      if (protocolType.LowerCaseEqualsLiteral("mailbox")) {
         m_srcIsPop3 = true;
         uint32_t msgSize;
         rv = srcHdr->GetMessageSize(&msgSize);
         if (NS_SUCCEEDED(rv)) m_srcSizeArray.AppendElement(msgSize);
         if (isMove) {
           rv = srcDB->CopyHdrFromExistingHdr(nsMsgKey_None, srcHdr, false,
                                              getter_AddRefs(copySrcHdr));
           nsMsgKey pseudoKey = nsMsgKey_None;
--- a/mailnews/imap/src/nsImapUrl.cpp
+++ b/mailnews/imap/src/nsImapUrl.cpp
@@ -622,17 +622,17 @@ NS_IMETHODIMP nsImapUrl::AddOnlineDirect
     if (PL_strcasecmp(onlineMailboxName, "INBOX")) {
       NS_ASSERTION(ns, "couldn't find namespace for host");
       nsAutoCString onlineDirWithDelimiter(onlineDir);
       // make sure the onlineDir ends with the hierarchy delimiter
       if (ns) {
         char delimiter = ns->GetDelimiter();
         if (delimiter && delimiter != kOnlineHierarchySeparatorUnknown) {
           // try to change the canonical online dir name to real dir name first
-          MsgReplaceChar(onlineDirWithDelimiter, '/', delimiter);
+          onlineDirWithDelimiter.ReplaceChar('/', delimiter);
           // make sure the last character is the delimiter
           if (onlineDirWithDelimiter.Last() != delimiter)
             onlineDirWithDelimiter += delimiter;
           if (!*onlineMailboxName)
             onlineDirWithDelimiter.SetLength(onlineDirWithDelimiter.Length() -
                                              1);
         }
       }
@@ -812,17 +812,17 @@ NS_IMETHODIMP nsImapUrl::AllocateCanonic
   // subdirectory
   // If this host has an online server directory configured
   LossyCopyUTF16toASCII(aString, onlineDir);
 
   if (currentPath && !onlineDir.IsEmpty()) {
     // By definition, the online dir must be at the root.
     if (delimiterToUse && delimiterToUse != kOnlineHierarchySeparatorUnknown) {
       // try to change the canonical online dir name to real dir name first
-      MsgReplaceChar(onlineDir, '/', delimiterToUse);
+      onlineDir.ReplaceChar('/', delimiterToUse);
       // Add the delimiter
       if (onlineDir.Last() != delimiterToUse) onlineDir += delimiterToUse;
     }
     int len = onlineDir.Length();
     if (!PL_strncmp(onlineDir.get(), currentPath, len)) {
       // This online path begins with the server sub directory
       currentPath += len;
 
--- a/mailnews/imap/src/nsImapUtils.cpp
+++ b/mailnews/imap/src/nsImapUtils.cpp
@@ -44,17 +44,17 @@ nsresult nsParseImapMessageURI(const cha
   int32_t folderEnd = -1;
   // imap-message uri's can have imap:// url strings tacked on the end,
   // e.g., when opening/saving attachments. We don't want to look for '#'
   // in that part of the uri, if the attachment name contains '#',
   // so check for that here.
   if (StringBeginsWith(uriStr, NS_LITERAL_CSTRING("imap-message")))
     folderEnd = uriStr.Find("imap://");
 
-  int32_t keySeparator = MsgRFindChar(uriStr, '#', folderEnd);
+  int32_t keySeparator = uriStr.RFindChar('#', folderEnd);
   if (keySeparator != -1) {
     int32_t keyEndSeparator = MsgFindCharInSet(uriStr, "/?&", keySeparator);
     nsAutoString folderPath;
     folderURI = StringHead(uriStr, keySeparator);
     folderURI.Cut(4, 8);  // cut out the _message part of imap-message:
     // folder uri's don't have fully escaped usernames.
     int32_t atPos = folderURI.FindChar('@');
     if (atPos != -1) {
@@ -75,17 +75,17 @@ nsresult nsParseImapMessageURI(const cha
       keyStr = Substring(uriStr, keySeparator + 1,
                          keyEndSeparator - (keySeparator + 1));
     else
       keyStr = Substring(uriStr, keySeparator + 1);
 
     *key = strtoul(keyStr.get(), nullptr, 10);
 
     if (part && keyEndSeparator != -1) {
-      int32_t partPos = MsgFind(uriStr, "part=", false, keyEndSeparator);
+      int32_t partPos = uriStr.Find("part=", false, keyEndSeparator);
       if (partPos != -1) {
         *part = ToNewCString(Substring(uriStr, keyEndSeparator));
       }
     }
   }
   return NS_OK;
 }
 
--- a/mailnews/import/outlook/src/MapiApi.cpp
+++ b/mailnews/import/outlook/src/MapiApi.cpp
@@ -1437,18 +1437,18 @@ void CMapiApi::ListPropertyValue(LPSProp
   s += "value: ";
   switch (PROP_TYPE(pVal->ulPropTag)) {
     case PT_STRING8:
       GetStringFromProp(pVal, strVal, FALSE);
       if (strVal.Length() > 60) {
         strVal.SetLength(60);
         strVal += "...";
       }
-      MsgReplaceSubstring(strVal, "\r", "\\r");
-      MsgReplaceSubstring(strVal, "\n", "\\n");
+      strVal.ReplaceSubstring("\r", "\\r");
+      strVal.ReplaceSubstring("\n", "\\n");
       s += strVal;
       break;
     case PT_LONG:
       s.AppendInt((int32_t)pVal->Value.l);
       s += ", 0x";
       s.AppendInt((int32_t)pVal->Value.l, 16);
       s += nBuff;
       break;
--- a/mailnews/import/outlook/src/nsOutlookMail.cpp
+++ b/mailnews/import/outlook/src/nsOutlookMail.cpp
@@ -680,18 +680,18 @@ nsresult nsOutlookMail::CreateList(const
   m_mapi.MAPIFreeBuffer(value);
 
   nsIAbDirectory *outList;
   rv = pDirectory->AddMailList(newList, &outList);
   return rv;
 }
 
 void nsOutlookMail::SanitizeValue(nsString &val) {
-  MsgReplaceSubstring(val, NS_LITERAL_STRING("\r\n"), NS_LITERAL_STRING(", "));
-  MsgReplaceChar(val, "\r\n", ',');
+  val.ReplaceSubstring(NS_LITERAL_STRING("\r\n"), NS_LITERAL_STRING(", "));
+  val.ReplaceChar("\r\n", ',');
 }
 
 void nsOutlookMail::SplitString(nsString &val1, nsString &val2) {
   // Find the last line if there is more than one!
   int32_t idx = val1.RFind("\x0D\x0A");
   int32_t cnt = 2;
   if (idx == -1) {
     cnt = 1;
--- a/mailnews/import/text/src/nsTextAddress.cpp
+++ b/mailnews/import/text/src/nsTextAddress.cpp
@@ -149,17 +149,17 @@ nsresult nsTextAddress::ReadRecord(nsIUn
       rv = NS_ERROR_FAILURE;
     } else {
       // Read the line and append it
       rv = aLineStream->ReadLine(line, &more);
       if (NS_SUCCEEDED(rv)) {
         if (!aLine.IsEmpty()) aLine.AppendLiteral(MSG_LINEBREAK);
         aLine.Append(line);
 
-        numQuotes += MsgCountChar(line, char16_t('"'));
+        numQuotes += line.CountChar(char16_t('"'));
       }
     }
     // Continue whilst everything is ok, and we have an odd number of quotes.
   } while (NS_SUCCEEDED(rv) && (numQuotes % 2 != 0));
 
   *aMore = more;
   return rv;
 }
@@ -317,17 +317,17 @@ bool nsTextAddress::GetField(const nsASt
 
   field.Append(nsDependentSubstring(aLine, startPos, fLen));
   field.Trim(kWhitespace);
 
   if (quoted) {
     int32_t offset = field.Find("\"\"");
     while (offset != -1) {
       field.Cut(offset, 1);
-      offset = MsgFind(field, "\"\"", false, offset + 1);
+      offset = field.Find("\"\"", false, offset + 1);
     }
   }
 
   return result;
 }
 
 nsresult nsTextAddress::DetermineDelim(nsIFile *aSrc) {
   nsCOMPtr<nsIInputStream> inputStream;
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -1318,18 +1318,18 @@ nsMsgLocalMailFolder::CopyMessages(nsIMs
   UpdateTimestamps(allowUndo);
   nsCString protocolType;
   rv = srcFolder->GetURI(protocolType);
   protocolType.SetLength(protocolType.FindChar(':'));
 
   // If we're offline and the source folder is imap or news, to do the
   // copy the message bodies MUST reside in offline storage.
   bool needOfflineBodies =
-      (WeAreOffline() && (MsgLowerCaseEqualsLiteral(protocolType, "imap") ||
-                          MsgLowerCaseEqualsLiteral(protocolType, "news")));
+      (WeAreOffline() && (protocolType.LowerCaseEqualsLiteral("imap") ||
+                          protocolType.LowerCaseEqualsLiteral("news")));
   int64_t totalMsgSize = 0;
   uint32_t numMessages = 0;
   bool allMsgsHaveOfflineStore = true;
   messages->GetLength(&numMessages);
   for (uint32_t i = 0; i < numMessages; i++) {
     nsCOMPtr<nsIMsgDBHdr> message(do_QueryElementAt(messages, i, &rv));
     if (NS_SUCCEEDED(rv) && message) {
       nsMsgKey key;
@@ -1438,17 +1438,17 @@ nsMsgLocalMailFolder::CopyMessages(nsIMs
                        isFolder, allowUndo);
 
   if (NS_FAILED(rv)) {
     ThrowAlertMsg("operationFailedFolderBusy", msgWindow);
     (void)OnCopyCompleted(srcSupport, false);
     return rv;
   }
 
-  if (!MsgLowerCaseEqualsLiteral(protocolType, "mailbox")) {
+  if (!protocolType.LowerCaseEqualsLiteral("mailbox")) {
     mCopyState->m_dummyEnvelopeNeeded = true;
     nsParseMailMessageState *parseMsgState = new nsParseMailMessageState();
     if (parseMsgState) {
       nsCOMPtr<nsIMsgDatabase> msgDb;
       mCopyState->m_parseMsgState = parseMsgState;
       GetDatabaseWOReparse(getter_AddRefs(msgDb));
       if (msgDb) parseMsgState->SetMailDB(msgDb);
     }
@@ -1467,19 +1467,19 @@ nsMsgLocalMailFolder::CopyMessages(nsIMs
         else
           msgTxn->SetTransactionType(nsIMessenger::eMoveMsg);
       } else
         msgTxn->SetTransactionType(nsIMessenger::eCopyMsg);
       msgTxn.swap(mCopyState->m_undoMsgTxn);
     }
   }
 
-  if (numMsgs > 1 && ((MsgLowerCaseEqualsLiteral(protocolType, "imap") &&
+  if (numMsgs > 1 && ((protocolType.LowerCaseEqualsLiteral("imap") &&
                        !allMsgsHaveOfflineStore) ||
-                      MsgLowerCaseEqualsLiteral(protocolType, "mailbox"))) {
+                      protocolType.LowerCaseEqualsLiteral("mailbox"))) {
     // For an imap source folder with more than one message to be copied that
     // are not all in offline storage, this fetches all the messages from the
     // imap server to do the copy. When source folder is "mailbox", this is not
     // a concern since source messages are in local storage.
     mCopyState->m_copyingMultipleMessages = true;
     rv = CopyMessagesTo(mCopyState->m_messages, keyArray, msgWindow, this,
                         isMove);
     if (NS_FAILED(rv)) {
--- a/mailnews/local/src/nsLocalUndoTxn.cpp
+++ b/mailnews/local/src/nsLocalUndoTxn.cpp
@@ -37,17 +37,17 @@ nsresult nsLocalMoveCopyMsgTxn::Init(nsI
   NS_ENSURE_SUCCESS(rv, rv);
   m_isMove = isMove;
 
   mUndoFolderListener = nullptr;
 
   nsCString protocolType;
   rv = srcFolder->GetURI(protocolType);
   protocolType.SetLength(protocolType.FindChar(':'));
-  if (MsgLowerCaseEqualsLiteral(protocolType, "imap")) m_srcIsImap4 = true;
+  if (protocolType.LowerCaseEqualsLiteral("imap")) m_srcIsImap4 = true;
   return nsMsgTxn::Init();
 }
 nsresult nsLocalMoveCopyMsgTxn::GetSrcIsImap(bool *isImap) {
   *isImap = m_srcIsImap4;
   return NS_OK;
 }
 nsresult nsLocalMoveCopyMsgTxn::SetSrcFolder(nsIMsgFolder *srcFolder) {
   nsresult rv = NS_ERROR_NULL_POINTER;
--- a/mailnews/local/src/nsLocalUtils.cpp
+++ b/mailnews/local/src/nsLocalUtils.cpp
@@ -219,11 +219,11 @@ nsresult nsCreateLocalBaseMessageURI(con
   baseMessageURI += tailURI;
 
   return NS_OK;
 }
 
 void nsEscapeNativePath(nsCString& nativePath) {
 #if defined(XP_WIN)
   nativePath.Insert('/', 0);
-  MsgReplaceChar(nativePath, '\\', '/');
+  nativePath.ReplaceChar('\\', '/');
 #endif
 }
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -497,17 +497,17 @@ nsresult nsPop3Protocol::InitializeInter
     if (msgwin) {
       nsCOMPtr<nsIDocShell> docshell;
       msgwin->GetRootDocShell(getter_AddRefs(docshell));
       ir = do_QueryInterface(docshell);
       nsCOMPtr<nsIInterfaceRequestor> notificationCallbacks;
       msgwin->GetNotificationCallbacks(getter_AddRefs(notificationCallbacks));
       if (notificationCallbacks) {
         nsCOMPtr<nsIInterfaceRequestor> aggregrateIR;
-        MsgNewInterfaceRequestorAggregation(notificationCallbacks, ir,
+        NS_NewInterfaceRequestorAggregation(notificationCallbacks, ir,
                                             getter_AddRefs(aggregrateIR));
         ir = aggregrateIR;
       }
     }
   }
 
   int32_t port = 0;
   m_url->GetPort(&port);
@@ -3887,17 +3887,17 @@ NS_IMETHODIMP nsPop3Protocol::CheckMessa
 /* Function for finding an APOP Timestamp and simple check
    it for its validity. If returning NS_OK m_ApopTimestamp
    contains the validated substring of m_commandResponse. */
 nsresult nsPop3Protocol::GetApopTimestamp() {
   int32_t startMark = m_commandResponse.Length(), endMark = -1;
 
   while (true) {
     // search for previous <
-    if ((startMark = MsgRFindChar(m_commandResponse, '<', startMark - 1)) < 0)
+    if ((startMark = m_commandResponse.RFindChar('<', startMark - 1)) < 0)
       return NS_ERROR_FAILURE;
 
     // search for next >
     if ((endMark = m_commandResponse.FindChar('>', startMark)) < 0) continue;
 
     // look for an @ between start and end as a raw test
     int32_t at = m_commandResponse.FindChar('@', startMark);
     if (at < 0 || at >= endMark) continue;
--- a/mailnews/mime/src/mimehdrs.cpp
+++ b/mailnews/mime/src/mimehdrs.cpp
@@ -523,22 +523,22 @@ int MimeHeaders_write_all_headers(MimeHe
     nsAutoCString name(Substring(head, colon));
     nsAutoCString hdr_value;
 
     if ((end - contents) > 0) {
       hdr_value = Substring(contents, end);
     }
 
     // MW Fixme: more?
-    bool convert_charset_only = MsgLowerCaseEqualsLiteral(name, "to") ||
-                                MsgLowerCaseEqualsLiteral(name, "from") ||
-                                MsgLowerCaseEqualsLiteral(name, "cc") ||
-                                MsgLowerCaseEqualsLiteral(name, "bcc") ||
-                                MsgLowerCaseEqualsLiteral(name, "reply-to") ||
-                                MsgLowerCaseEqualsLiteral(name, "sender");
+    bool convert_charset_only = name.LowerCaseEqualsLiteral("to") ||
+                                name.LowerCaseEqualsLiteral("from") ||
+                                name.LowerCaseEqualsLiteral("cc") ||
+                                name.LowerCaseEqualsLiteral("bcc") ||
+                                name.LowerCaseEqualsLiteral("reply-to") ||
+                                name.LowerCaseEqualsLiteral("sender");
     MimeHeaders_convert_header_value(opt, hdr_value, convert_charset_only);
     // if we're saving as html, we need to convert headers from utf8 to message
     // charset, if any
     if (opt->format_out == nsMimeOutput::nsMimeMessageSaveAs && charset) {
       nsAutoCString convertedStr;
       if (NS_SUCCEEDED(nsMsgI18NConvertFromUnicode(
               nsDependentCString(charset), NS_ConvertUTF8toUTF16(hdr_value),
               convertedStr))) {
--- a/mailnews/mime/src/nsStreamConverter.cpp
+++ b/mailnews/mime/src/nsStreamConverter.cpp
@@ -288,18 +288,18 @@ nsresult nsStreamConverter::DetermineOut
 
     if (*format) {
       mOverrideFormat = "raw";
 
       // set mOutputFormat to the supplied format, ensure that we replace any
       // %2F strings with the slash character
       const char *nextField = PL_strpbrk(format, "&; ");
       mOutputFormat.Assign(format, nextField ? nextField - format : -1);
-      MsgReplaceSubstring(mOutputFormat, "%2F", "/");
-      MsgReplaceSubstring(mOutputFormat, "%2f", "/");
+      mOutputFormat.ReplaceSubstring("%2F", "/");
+      mOutputFormat.ReplaceSubstring("%2f", "/");
 
       // Don't muck with this data!
       *aNewType = nsMimeOutput::nsMimeMessageRaw;
       return NS_OK;
     }
   }
 
   // is this is a part that should just come out raw
--- a/mailnews/news/src/nsNNTPProtocol.cpp
+++ b/mailnews/news/src/nsNNTPProtocol.cpp
@@ -23,16 +23,17 @@
 #include "prtime.h"
 #include "prerror.h"
 #include "nsString.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Services.h"
 #include "mozilla/SlicedInputStream.h"
 #include "mozilla/mailnews/MimeHeaderParser.h"
+#include "mozilla/Utf8.h"
 #include "nsContentUtils.h"
 #include "nsIURIMutator.h"
 
 #include "prprf.h"
 
 /* include event sink interfaces for news */
 
 #include "nsIMsgSearchSession.h"
@@ -882,17 +883,17 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI 
   m_runningURL->GetNewsAction(&m_newsAction);
 
   SetIsBusy(true);
 
   rv = ParseURL(aURL, group, m_messageID);
   NS_ASSERTION(NS_SUCCEEDED(rv), "failed to parse news url");
   // if (NS_FAILED(rv)) return rv;
   // XXX group returned from ParseURL is assumed to be in UTF-8
-  NS_ASSERTION(MsgIsUTF8(group), "newsgroup name is not in UTF-8");
+  NS_ASSERTION(mozilla::IsUtf8(group), "newsgroup name is not in UTF-8");
   NS_ASSERTION(m_nntpServer, "Parsing must result in an m_nntpServer");
 
   MOZ_LOG(NNTP, LogLevel::Info,
           ("(%p) m_messageID = %s", this, m_messageID.get()));
   MOZ_LOG(NNTP, LogLevel::Info, ("(%p) group = %s", this, group.get()));
   MOZ_LOG(NNTP, LogLevel::Info, ("(%p) m_key = %d", this, m_key));
 
   if (m_newsAction == nsINntpUrl::ActionFetchArticle ||
--- a/mailnews/news/src/nsNntpIncomingServer.cpp
+++ b/mailnews/news/src/nsNntpIncomingServer.cpp
@@ -29,16 +29,17 @@
 #include "nsISimpleEnumerator.h"
 #include "nsMsgUtils.h"
 #include "mozilla/Services.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/XULTreeElement.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/LoadInfo.h"
+#include "mozilla/Utf8.h"
 
 #define INVALID_VERSION 0
 #define VALID_VERSION 2
 #define NEW_NEWS_DIR_NAME "News"
 #define PREF_MAIL_NEWSRC_ROOT "mail.newsrc_root"
 #define PREF_MAIL_NEWSRC_ROOT_REL "mail.newsrc_root-rel"
 #define PREF_MAILNEWS_VIEW_DEFAULT_CHARSET "mailnews.view_default_charset"
 #define HOSTINFO_FILE_NAME "hostinfo.dat"
@@ -1020,17 +1021,17 @@ nsNntpIncomingServer::UpdateSubscribed()
   for (uint32_t i = 0; i < length; ++i)
     SetAsSubscribed(mSubscribedNewsgroups[i]);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNntpIncomingServer::AddTo(const nsACString &aName, bool addAsSubscribed,
                             bool aSubscribable, bool changeIfExists) {
-  NS_ASSERTION(MsgIsUTF8(aName), "Non-UTF-8 newsgroup name");
+  NS_ASSERTION(mozilla::IsUtf8(aName), "Non-UTF-8 newsgroup name");
   nsresult rv = EnsureInner();
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = AddGroupOnServer(aName);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mInner->AddTo(aName, addAsSubscribed, aSubscribable, changeIfExists);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1117,17 +1118,17 @@ nsresult nsNntpIncomingServer::HandleLin
   if (mHasSeenBeginGroups) {
     // v1 hostinfo files had additional data fields delimited by commas.
     // with v2 hostinfo files, the additional data fields are removed.
     char *commaPos = (char *)PL_strchr(line, ',');
     if (commaPos) *commaPos = 0;
 
       // newsrc entries are all in UTF-8
 #ifdef DEBUG_jungshik
-    NS_ASSERTION(MsgIsUTF8(nsDependentCString(line)),
+    NS_ASSERTION(mozilla::IsUtf8(nsDependentCString(line)),
                  "newsrc line is not utf-8");
 #endif
     nsresult rv = AddTo(nsDependentCString(line), false, true, true);
     NS_ASSERTION(NS_SUCCEEDED(rv), "failed to add line");
     if (NS_SUCCEEDED(rv)) {
       // since we've seen one group, we can claim we've loaded the
       // hostinfo file
       mHostInfoLoaded = true;
@@ -1503,35 +1504,34 @@ nsNntpIncomingServer::GetCanCreateFolder
   // No folder creation on news servers. Return false.
   *aCanCreateFoldersOnServer = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNntpIncomingServer::SetSearchValue(const nsAString &aSearchValue) {
   nsCString searchValue = NS_ConvertUTF16toUTF8(aSearchValue);
-  MsgCompressWhitespace(searchValue);
+  searchValue.CompressWhitespace();
 
   if (mTree) {
     mTree->BeginUpdateBatch();
     mTree->RowCountChanged(
         0, -static_cast<int32_t>(mSubscribeSearchResult.Length()));
   }
 
   nsTArray<nsCString> searchStringParts;
   if (!searchValue.IsEmpty()) ParseString(searchValue, ' ', searchStringParts);
 
   mSubscribeSearchResult.Clear();
   uint32_t length = mGroupsOnServer.Length();
   for (uint32_t i = 0; i < length; i++) {
     // check that all parts of the search string occur
     bool found = true;
     for (uint32_t j = 0; j < searchStringParts.Length(); ++j) {
-      if (MsgFind(mGroupsOnServer[i], searchStringParts[j], true, 0) ==
-          kNotFound) {
+      if (mGroupsOnServer[i].Find(searchStringParts[j], true, 0) == kNotFound) {
         found = false;
         break;
       }
     }
 
     if (found) mSubscribeSearchResult.AppendElement(mGroupsOnServer[i]);
   }
 
--- a/mailnews/news/src/nsNntpService.cpp
+++ b/mailnews/news/src/nsNntpService.cpp
@@ -41,16 +41,17 @@
 #include "nsArrayUtils.h"
 #include "nsIStreamListener.h"
 #include "nsIInputStream.h"
 #include "nsIURIMutator.h"
 #include "nsTArray.h"
 #include "nsDocShellLoadState.h"
 #include "nsContentUtils.h"
 #include "mozilla/LoadInfo.h"
+#include "mozilla/Utf8.h"
 
 #include "../../base/src/MailnewsLoadContextInfo.h"
 
 #undef GetPort  // XXX Windows!
 #undef SetPort  // XXX Windows!
 
 #define PREF_MAIL_ROOT_NNTP \
   "mail.root.nntp"  // old - for backward compatibility only
@@ -608,17 +609,17 @@ nsresult nsNntpService::FindServerWithNe
   nsCOMPtr<nsIMsgAccountManager> accountManager =
       do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIArray> servers;
   rv = accountManager->GetAllServers(getter_AddRefs(servers));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  NS_ASSERTION(MsgIsUTF8(groupName), "newsgroup is not in UTF-8");
+  NS_ASSERTION(mozilla::IsUtf8(groupName), "newsgroup is not in UTF-8");
 
   // XXX TODO
   // this only looks at the list of subscribed newsgroups.
   // fix to use the hostinfo.dat information
 
   uint32_t length;
   rv = servers->GetLength(&length);
   NS_ENSURE_SUCCESS(rv, rv);