MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / string2byteString

Function string2byteString

src/background/utils/requests-core.js:190–194  ·  view source on GitHub ↗

* Returns a UTF8-encoded binary string i.e. one byte per character. * Returns the original string in case it was already within ASCII.

(str)

Source from the content-addressed store, hash-verified

188 * Returns the original string in case it was already within ASCII.
189 */
190function string2byteString(str) {
191 if (!/[\u0080-\uFFFF]/.test(str)) return str;
192 if (!encoder) encoder = new TextEncoder();
193 return buffer2string(encoder.encode(str));
194}
195
196// Chrome 74-91 needs an extraHeaders listener at tab load start, https://crbug.com/1074282
197// We're attaching a no-op in non-blocking mode so it's very lightweight and fast.

Callers 1

encodeWebRequestHeaderFunction · 0.85

Calls 2

buffer2stringFunction · 0.90
testMethod · 0.45

Tested by

no test coverage detected