mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
string_bytes: add StringBytes::IsValidString()
Performs a quick, non-exhaustive check on the input string to see if it's compatible with the specified string encoding. Curently it only checks that hex strings have a length that is a multiple of two.
This commit is contained in:
1 parent
4881a6a9a3
commit
dce26ccea1
2 files changed
+12
No files matched your search
@@ -36,6 +36,11 @@ using v8::Value;
|
||||
|
||||
class StringBytes {
|
||||
public:
|
||||
// Does the string match the encoding? Quick but non-exhaustive.
|
||||
// Example: a HEX string must have a length that's a multiple of two.
|
||||
// FIXME(bnoordhuis) IsMaybeValidString()? Naming things is hard...
|
||||
static bool IsValidString(Handle<String> string, enum encoding enc);
|
||||
|
||||
// Fast, but can be 2 bytes oversized for Base64, and
|
||||
// as much as triple UTF-8 strings <= 65536 chars in length
|
||||
static size_t StorageSize(Handle<Value> val, enum encoding enc);
|
||||
|
||||
Reference in new issue
Block a user