Changeset View
Changeset View
Standalone View
Standalone View
src/utilstrencodings.h
Show First 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | bool ConvertBits(O &out, I it, I end) { | ||||
// We have remaining bits to encode so we do pad. | // We have remaining bits to encode so we do pad. | ||||
if (pad && bits) { | if (pad && bits) { | ||||
out.push_back((acc << (tobits - bits)) & maxv); | out.push_back((acc << (tobits - bits)) & maxv); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/** | |||||
* Converts the given character to its lowercase equivalent. | |||||
* This function is locale independent. It only converts uppercase | |||||
* characters in the standard 7-bit ASCII range. | |||||
* @param[in] c the character to convert to lowercase. | |||||
* @return the lowercase equivalent of c; or the argument | |||||
* if no conversion is possible. | |||||
*/ | |||||
constexpr unsigned char ToLower(unsigned char c) { | |||||
return (c >= 'A' && c <= 'Z' ? (c - 'A') + 'a' : c); | |||||
} | |||||
/** | |||||
* Converts the given string to its lowercase equivalent. | |||||
* This function is locale independent. It only converts uppercase | |||||
* characters in the standard 7-bit ASCII range. | |||||
* @param[in,out] str the string to convert to lowercase. | |||||
*/ | |||||
void Downcase(std::string &str); | |||||
/** | |||||
* Converts the given character to its uppercase equivalent. | |||||
* This function is locale independent. It only converts lowercase | |||||
* characters in the standard 7-bit ASCII range. | |||||
* @param[in] c the character to convert to uppercase. | |||||
* @return the uppercase equivalent of c; or the argument | |||||
* if no conversion is possible. | |||||
*/ | |||||
constexpr unsigned char ToUpper(unsigned char c) { | |||||
return (c >= 'a' && c <= 'z' ? (c - 'a') + 'A' : c); | |||||
} | |||||
/** | |||||
* Capitalizes the first character of the given string. | |||||
* This function is locale independent. It only capitalizes the | |||||
* first character of the argument if it has an uppercase equivalent | |||||
* in the standard 7-bit ASCII range. | |||||
* @param[in] str the string to capitalize. | |||||
* @return string with the first letter capitalized. | |||||
*/ | |||||
std::string Capitalize(std::string str); | |||||
#endif // BITCOIN_UTILSTRENCODINGS_H | #endif // BITCOIN_UTILSTRENCODINGS_H |