Index: src/wasm/utf8.h |
diff --git a/src/wasm/utf8.h b/src/wasm/utf8.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..50eadbffb8e3d9506f4d10bf9f232a08ac144d5c |
--- /dev/null |
+++ b/src/wasm/utf8.h |
@@ -0,0 +1,26 @@ |
+// Copyright 2016 the V8 project authors. All rights reserved. |
titzer
2016/05/12 08:29:14
I think we should put this in src/base, since it's
Clemens Hammacher
2016/05/12 11:21:41
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef V8_WASM_UNICODE_H_ |
+#define V8_WASM_UNICODE_H_ |
+ |
+#include <stdint.h> |
+ |
+// UTF8 validation is currently only needed for WASM, so we add this utility |
+// here. |
+ |
+namespace v8 { |
+namespace internal { |
+namespace wasm { |
+ |
+// Check if byte buffer contains a valid UTF8-encoded string. |
+// Returns true if multi-byte decoding succeeded and all decoded characters are |
+// valid character codepoints. Returns false otherwise. |
+bool IsValidUtf8(const uint8_t *buf, int32_t len); |
+ |
+} // namespace wasm |
+} // namespace internal |
+} // namespace v8 |
+ |
+#endif // V8_WASM_UNICODE_H_ |