-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
034f776
commit 741b768
Showing
35 changed files
with
6,758 additions
and
597 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include "root.h" | ||
|
||
#include <wtf/text/WTFString.h> | ||
#include <wtf/text/CString.h> | ||
|
||
namespace Bun { | ||
class UTF8View { | ||
public: | ||
UTF8View() | ||
{ | ||
m_isCString = false; | ||
m_underlying = {}; | ||
m_view = {}; | ||
} | ||
|
||
UTF8View(WTF::StringView view) | ||
{ | ||
if (view.is8Bit() && view.containsOnlyASCII()) { | ||
m_view = view; | ||
} else { | ||
m_underlying = view.utf8(); | ||
m_isCString = true; | ||
} | ||
} | ||
UTF8View(const WTF::String& str) | ||
{ | ||
if (str.is8Bit() && str.containsOnlyASCII()) { | ||
m_view = str; | ||
} else { | ||
m_underlying = str.utf8(); | ||
m_isCString = true; | ||
} | ||
} | ||
|
||
WTF::CString m_underlying {}; | ||
WTF::StringView m_view {}; | ||
bool m_isCString { false }; | ||
|
||
std::span<const char> span() const | ||
{ | ||
if (m_isCString) { | ||
return std::span(reinterpret_cast<const char*>(m_underlying.data()), m_underlying.length()); | ||
} | ||
|
||
return std::span(reinterpret_cast<const char*>(m_view.span8().data()), m_view.length()); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.