MCPcopy Index your code
hub / github.com/dataease/SQLBot / utf8ToBytes

Function utf8ToBytes

frontend/public/swagger-ui-bundle.js:22767–22814  ·  view source on GitHub ↗
(s, o)

Source from the content-addressed store, hash-verified

22765 ))
22766 const j = /[^+/0-9A-Za-z-_]/g
22767 function utf8ToBytes(s, o) {
22768 let i
22769 o = o || 1 / 0
22770 const a = s.length
22771 let u = null
22772 const _ = []
22773 for (let w = 0; w < a; ++w) {
22774 if (((i = s.charCodeAt(w)), i > 55295 && i < 57344)) {
22775 if (!u) {
22776 if (i > 56319) {
22777 ;(o -= 3) > -1 && _.push(239, 191, 189)
22778 continue
22779 }
22780 if (w + 1 === a) {
22781 ;(o -= 3) > -1 && _.push(239, 191, 189)
22782 continue
22783 }
22784 u = i
22785 continue
22786 }
22787 if (i < 56320) {
22788 ;((o -= 3) > -1 && _.push(239, 191, 189), (u = i))
22789 continue
22790 }
22791 i = 65536 + (((u - 55296) << 10) | (i - 56320))
22792 } else u && (o -= 3) > -1 && _.push(239, 191, 189)
22793 if (((u = null), i < 128)) {
22794 if ((o -= 1) < 0) break
22795 _.push(i)
22796 } else if (i < 2048) {
22797 if ((o -= 2) < 0) break
22798 _.push((i >> 6) | 192, (63 & i) | 128)
22799 } else if (i < 65536) {
22800 if ((o -= 3) < 0) break
22801 _.push((i >> 12) | 224, ((i >> 6) & 63) | 128, (63 & i) | 128)
22802 } else {
22803 if (!(i < 1114112)) throw new Error('Invalid code point')
22804 if ((o -= 4) < 0) break
22805 _.push(
22806 (i >> 18) | 240,
22807 ((i >> 12) & 63) | 128,
22808 ((i >> 6) & 63) | 128,
22809 (63 & i) | 128
22810 )
22811 }
22812 }
22813 return _
22814 }
22815 function base64ToBytes(s) {
22816 return a.toByteArray(
22817 (function base64clean(s) {

Callers 2

byteLengthFunction · 0.85
utf8WriteFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected