Skip to content
Bitcoin Roots

v30.3-roots.1 · Commit 2: [PATCH 02/68] feat(runtime): preserve Roots operator controls on Core 30.3

src/util/strencodings.h

Before: src/util/strencodings.h · After: src/util/strencodings.h

File metadata
index 01063858047cc2c40f8d2d1bcd0f83c18e98db99..6f12543121bdeeb94d45ee1c71e295bce04b7f4b 100644

Download original patch · Release notes

Diff rows 1–25 of 25. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

src/util/strencodings.h CHANGED
@@ -33,6 +33,7 @@ enum SafeChars
33
  SAFE_CHARS_UA_COMMENT, //!< BIP-0014 subset
34
  SAFE_CHARS_FILENAME, //!< Chars allowed in filenames
35
  SAFE_CHARS_URI, //!< Chars allowed in URIs (RFC 3986)
 
36
  };
37
 
38
  /**
@@ -59,7 +60,7 @@ enum class ByteUnit : uint64_t {
59
  * @param[in] rule The set of safe chars to choose (default: least restrictive)
60
  * @return A new string without unsafe chars
61
  */
62
- std::string SanitizeString(std::string_view str, int rule = SAFE_CHARS_DEFAULT);
63
  /** Parse the hex string into bytes (uint8_t or std::byte). Ignores whitespace. Returns nullopt on invalid input. */
64
  template <typename Byte = std::byte>
65
  std::optional<std::vector<Byte>> TryParseHex(std::string_view str);
@@ -162,8 +163,8 @@ constexpr bool IsDigit(char c)
162
  * @param[in] c character to test
163
  * @return true if the argument is a whitespace character; otherwise false
164
  */
165
- constexpr inline bool IsSpace(char c) noexcept {
166
- return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
167
  }
168
 
169
  /**
 
33
  SAFE_CHARS_UA_COMMENT, //!< BIP-0014 subset
34
  SAFE_CHARS_FILENAME, //!< Chars allowed in filenames
35
  SAFE_CHARS_URI, //!< Chars allowed in URIs (RFC 3986)
36
+ SAFE_CHARS_PRINTABLE, //!< The full set of printable chars
37
  };
38
 
39
  /**
 
60
  * @param[in] rule The set of safe chars to choose (default: least restrictive)
61
  * @return A new string without unsafe chars
62
  */
63
+ std::string SanitizeString(std::string_view str, int rule = SAFE_CHARS_DEFAULT, bool escape = false);
64
  /** Parse the hex string into bytes (uint8_t or std::byte). Ignores whitespace. Returns nullopt on invalid input. */
65
  template <typename Byte = std::byte>
66
  std::optional<std::vector<Byte>> TryParseHex(std::string_view str);
 
163
  * @param[in] c character to test
164
  * @return true if the argument is a whitespace character; otherwise false
165
  */
166
+ constexpr inline bool IsSpace(const char c) noexcept {
167
+ return c <= ' ' && (c == ' ' || (c >= '\t' && c <= '\r'));
168
  }
169
 
170
  /**