#include "sbStringUtils.h"
#include <prprf.h>
#include <nsDataHashtable.h>
#include <nsIStringBundle.h>
#include <nsIStringEnumerator.h>
#include <nsICharsetConverterManager.h>
#include <nsIUnicodeDecoder.h>
#include <nsServiceManagerUtils.h>
#include <sbIStringBundleService.h>
#include <sbMemoryUtils.h>
Go to the source code of this file.
Functions | |
PRInt32 | nsString_FindCharInSet (const nsAString &aString, const char *aPattern, PRInt32 aOffset) |
void | AppendInt (nsAString &str, PRUint64 val) |
PRInt64 | nsString_ToInt64 (const nsAString &str, nsresult *rv) |
PRUint64 | nsString_ToUint64 (const nsAString &str, nsresult *rv) |
void | SB_CompressWhitespace (nsAString &aString, PRBool aLeading, PRBool aTrailing) |
nsresult | SB_StringEnumeratorEquals (nsIStringEnumerator *aLeft, nsIStringEnumerator *aRight, PRBool *_retval) |
void | nsString_ReplaceChar (nsAString &aString, const nsAString &aOldChars, const PRUnichar aNewChar) |
void | nsCString_ReplaceChars (nsACString &aOldString, const nsACString &aOldChars, const char aNewChar) |
void | nsString_ReplaceSubstring (nsAString &aString, const nsAString &aOldString, const nsAString &aNewString) |
PRBool | IsLikelyUTF8 (const nsACString &aString) |
PRBool | IsUTF8 (const nsACString &aString) |
void | nsString_Split (const nsAString &aString, const nsAString &aDelimiter, nsTArray< nsString > &aSubStringArray) |
void | nsCString_Split (const nsACString &aString, const nsACString &aDelimiter, nsTArray< nsCString > &aSubStringArray) |
nsString | SB_FormatISO8601TimeString (PRTime aTime) |
nsresult | SB_ParseISO8601TimeString (const nsAString &aISO8601TimeString, PRTime *aTime) |
nsresult | SBGetLocalizedString (nsAString &aString, const nsAString &aKey, const nsAString &aDefault, class nsIStringBundle *aStringBundle) |
nsresult | SBGetLocalizedString (nsAString &aString, const nsAString &aKey) |
nsresult | SBGetLocalizedString (nsAString &aString, const char *aKey, const char *aDefault, class nsIStringBundle *aStringBundle) |
nsresult | SBGetLocalizedFormattedString (nsAString &aString, const nsAString &aKey, const nsTArray< nsString > &aParams, const nsAString &aDefault, class nsIStringBundle *aStringBundle) |
void AppendInt | ( | nsAString & | str, |
PRUint64 | val | ||
) |
PRBool IsLikelyUTF8 | ( | const nsACString & | aString | ) |
Return true if the given string is possibly UTF8 (i.e. it errs on the side of returning true)
Note that it assumes all 7-bit encodings are utf8, and doesn't check for invalid characters (e.g. 0xFFFE, surrogates). This is a weaker check than the nsReadableUtils version.
Definition at line 274 of file sbStringUtils.cpp.
PRBool IsUTF8 | ( | const nsACString & | aString | ) |
Returns true if the given string is UTF8
Note that this actually decodes the UTF8 string so it is significantly slower than IsLikelyUTF8.
Definition at line 328 of file sbStringUtils.cpp.
void nsCString_ReplaceChars | ( | nsACString & | aOldString, |
const nsACString & | aOldChars, | ||
const char | aNewChar | ||
) |
void nsCString_Split | ( | const nsACString & | aString, |
const nsACString & | aDelimiter, | ||
nsTArray< nsCString > & | aSubStringArray | ||
) |
Split the string specified by aString into sub-strings using the delimiter specified by aDelimiter and place the sub-strings in the array specified by aStringArray.
aString | String to split. |
aDelimiter | Sub-string delimiter. |
aSubStringArray | Array of sub-strings. |
Definition at line 394 of file sbStringUtils.cpp.
PRInt32 nsString_FindCharInSet | ( | const nsAString & | aString, |
const char * | aPattern, | ||
PRInt32 | aOffset = 0 |
||
) |
Definition at line 38 of file sbStringUtils.cpp.
void nsString_ReplaceChar | ( | nsAString & | aString, |
const nsAString & | aOldChars, | ||
const PRUnichar | aNewChar | ||
) |
Searches a string for any occurences of any character of a set and replace them with a replacement character. Modifies the string in-place.
Definition at line 225 of file sbStringUtils.cpp.
void nsString_ReplaceSubstring | ( | nsAString & | aString, |
const nsAString & | aOldString, | ||
const nsAString & | aNewString | ||
) |
Searches a string for any occurences of the substring and replaces it with the replacement string. Modifies the string in-place.
Definition at line 252 of file sbStringUtils.cpp.
void nsString_Split | ( | const nsAString & | aString, |
const nsAString & | aDelimiter, | ||
nsTArray< nsString > & | aSubStringArray | ||
) |
Split the string specified by aString into sub-strings using the delimiter specified by aDelimiter and place the sub-strings in the array specified by aStringArray.
aString | String to split. |
aDelimiter | Sub-string delimiter. |
aSubStringArray | Array of sub-strings. |
Definition at line 353 of file sbStringUtils.cpp.
PRInt64 nsString_ToInt64 | ( | const nsAString & | str, |
nsresult * | rv | ||
) |
Definition at line 66 of file sbStringUtils.cpp.
PRUint64 nsString_ToUint64 | ( | const nsAString & | str, |
nsresult * | rv | ||
) |
Definition at line 91 of file sbStringUtils.cpp.
void SB_CompressWhitespace | ( | nsAString & | aString, |
PRBool | aLeading, | ||
PRBool | aTrailing | ||
) |
This is originated from CompressWhitespace in nsStringAPI, with modification. Make sure to update it when the upstream is changed.
Definition at line 120 of file sbStringUtils.cpp.
nsString SB_FormatISO8601TimeString | ( | PRTime | aTime | ) |
Creates an ISO 8610 formatted time string from the aTime passed in
aTime | The time to create the formatted string |
Definition at line 434 of file sbStringUtils.cpp.
nsresult SB_ParseISO8601TimeString | ( | const nsAString & | aISO8601TimeString, |
PRTime * | aTime | ||
) |
Parse the ISO 8601 formatted time string specified by aISO8601TimeString and return the time in aTime.
aISO8601TimeString | ISO 8601 formatted time string to parse. |
aTime | Returned time. |
Definition at line 444 of file sbStringUtils.cpp.
nsresult SB_StringEnumeratorEquals | ( | nsIStringEnumerator * | aLeft, |
nsIStringEnumerator * | aRight, | ||
PRBool * | _retval | ||
) |
Definition at line 165 of file sbStringUtils.cpp.
nsresult SBGetLocalizedFormattedString | ( | nsAString & | aString, |
const nsAString & | aKey, | ||
const nsTArray< nsString > & | aParams, | ||
const nsAString & | aDefault, | ||
class nsIStringBundle * | aStringBundle | ||
) |
Get and return in aString the formatted localized string with the key specified by aKey using the format parameters specified by aParams and the string bundle specified by aStringBundle. If the string cannot be found, return the default string specified by aDefault; if aDefault is void, return aKey. If aStringBundle is not specified, use the main Songbird string bundle.
aString | Returned localized string. |
aKey | Localized string key. |
aParams | Format params array. |
aDefault | Optional default string. |
aStringBundle | Optional string bundle. |
Definition at line 593 of file sbStringUtils.cpp.
nsresult SBGetLocalizedString | ( | nsAString & | aString, |
const nsAString & | aKey, | ||
const nsAString & | aDefault, | ||
class nsIStringBundle * | aStringBundle | ||
) |
Get and return in aString the localized string with the key specified by aKey using the string bundle specified by aStringBundle. If the string cannot be found, return the default string specified by aDefault; if aDefault is void, return aKey.
If aStringBundle is not specified, use the main Songbird string bundle.
aString | Returned localized string. |
aKey | Localized string key. |
aDefault | Optional default string. |
aStringBundle | Optional string bundle. |
Definition at line 513 of file sbStringUtils.cpp.
nsresult SBGetLocalizedString | ( | nsAString & | aString, |
const nsAString & | aKey | ||
) |
nsresult SBGetLocalizedString | ( | nsAString & | aString, |
const char * | aKey, | ||
const char * | aDefault, | ||
class nsIStringBundle * | aStringBundle | ||
) |