Base64 coding problem in js

recently encountered a rather bizarre problem, string--> base64, but it also involves gbk coding. The code is as follows:

var content_base64 = "CgkJCgkJCQk8Y29uZGl0aW9ucyB0eXBlPSJBTkQiPgoJCQkJCTxzeXNDb25kaXRpb25zIHR5cGU9Inx8Ij4KCQkJCQk8c3lzQ29uZGl0aW9uIG5hbWU9ItDCzsS1tSIgZXhwcmVzc2lvbj0iS0dselRtVjNSRzlqS0NrcElBPT0iLz4KCQkJCQk8c3lzQ29uZGl0aW9uIG5hbWU9IrWxx7C0psDtyMsiIGV4cHJlc3Npb249IktHbHpRM1Z5VlhObGNpZ3BLU0E9Ii8+CgkJCQkJPC9zeXNDb25kaXRpb25zPgoJCQkJPC9jb25kaXRpb25zPgoJCQk=";
var arrayBuffer = _base64ToArrayBuffer(content_base64);
var content = new TextDecoder("gbk").decode(arrayBuffer);
console.log(content);

function _base64ToArrayBuffer(base64) {
    var binary_string =  window.atob(base64);
    var len = binary_string.length;
    var bytes = new Uint8Array( len );
    for (var i = 0; i < len; iPP)        {
        bytes[i] = binary_string.charCodeAt(i);
    }
    return bytes.buffer;
}

function _arrayBufferToBase64( buffer ) {
    var binary = "";
    var bytes = new Uint8Array( buffer );
    var len = bytes.byteLength;
    for (var i = 0; i < len; iPP) {
        binary += String.fromCharCode( bytes[ i ] );
    }
    return window.btoa( binary );
}

clipboard.png

how to convert the string back to base64 (gbk encoding format) ?


the other way around

var arrayBuffer = new TextEncoder("gbk").encode(content);
var content_base64 =_arrayBufferToBase64(arrayBuffer)
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-1b35c81-2bfa3.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-1b35c81-2bfa3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?