mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 18:59:21 +00:00
Count the line pos, offset and size of compilation message in UTF-16
This patch counts the line position, offset and size of the compilation message in UTF-16 and saves them to WGPUCompilationMessage to align the latest WebGPU SPEC. Bug: dawn:1357 Change-Id: If8f4026bd5b4a64a078e100762b6d1f61da50053 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115640 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
3d2caaae47
commit
f7beb85fd1
@@ -427,6 +427,10 @@ std::pair<CodePoint, size_t> Decode(const uint8_t* ptr, size_t len) {
|
||||
return {c, n};
|
||||
}
|
||||
|
||||
std::pair<CodePoint, size_t> Decode(std::string_view utf8_string) {
|
||||
return Decode(reinterpret_cast<const uint8_t*>(utf8_string.data()), utf8_string.size());
|
||||
}
|
||||
|
||||
bool IsASCII(std::string_view str) {
|
||||
for (auto c : str) {
|
||||
if (c & 0x80) {
|
||||
|
||||
@@ -69,6 +69,12 @@ namespace utf8 {
|
||||
/// If the next code point cannot be decoded then returns [0,0].
|
||||
std::pair<CodePoint, size_t> Decode(const uint8_t* ptr, size_t len);
|
||||
|
||||
/// Decodes the first code point in the utf8 string.
|
||||
/// @param utf8_string the string view that contains the utf8 sequence
|
||||
/// @returns a pair of CodePoint and width in code units (bytes).
|
||||
/// If the next code point cannot be decoded then returns [0,0].
|
||||
std::pair<CodePoint, size_t> Decode(std::string_view utf8_string);
|
||||
|
||||
/// @returns true if all the utf-8 code points in the string are ASCII
|
||||
/// (code-points 0x00..0x7f).
|
||||
bool IsASCII(std::string_view);
|
||||
|
||||
Reference in New Issue
Block a user