How do I convert a string to a binary array?

the string needs to be converted to a binary sequence. Since new TextEncoder ("utf-8") .encode (str), is not compatible with IE browsers, you need to find another way to replace the TextEncoder method.

Mar.02,2021

uncertain and incompatible, it seems that IE is not very compatible when it comes to ArrayBuffer and ES6.

function stringToByte(str) {

    var bytes = new Array();  
    var len, c;  
    len = str.length;  
    for(var i = 0; i < len; iPP) {  
        c = str.charCodeAt(i);  
        if(c >= 0x010000 && c <= 0x10FFFF) {  
            bytes.push(((c >> 18) & 0x07) | 0xF0);  
            bytes.push(((c >> 12) & 0x3F) | 0x80);  
            bytes.push(((c >> 6) & 0x3F) | 0x80);  
            bytes.push((c & 0x3F) | 0x80);  
        } else if(c >= 0x000800 && c <= 0x00FFFF) {  
            bytes.push(((c >> 12) & 0x0F) | 0xE0);  
            bytes.push(((c >> 6) & 0x3F) | 0x80);  
            bytes.push((c & 0x3F) | 0x80);  
        } else if(c >= 0x000080 && c <= 0x0007FF) {  
            bytes.push(((c >> 6) & 0x1F) | 0xC0);  
            bytes.push((c & 0x3F) | 0x80);  
        } else {  
            bytes.push(c & 0xFF);  
        }  
    }  
    return new Uint8Array(bytes);  
}  
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c16a-2b02b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c16a-2b02b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?