Removing " " from contents of a text file

  • Goal: I want to show the text from a .txt file i recieved through an API, but cant decode it due to the " " around its body.

  • Steps: Ive tried making a second query with split, slice, subtr, replace commands, which dosent work at all!

  • Details: would be happy for a code snippet that removes the "" around my text string aswell as decodes the text from Base64 and also includes the nordic characters Å, Ä, and Ö!

Im working on an easy interface for showing results from the Gemini API, and some of the results are returned in Swedish!

Hello @Jonathan_Andersson, using javascript you can try something like this:

function processText(encodedText) {

    if (encodedText.startsWith('"') && encodedText.endsWith('"')) {
        encodedText = encodedText.slice(1, -1);
    }

    let decodedText = atob(encodedText);

    return decodedText;
}

let encodedText = '"U29tZSBlbmNvZGVkIHRleHQgaW5jbHVkaW5nIMSBw6Qg4piM4piE4piI4piJLiI="';
let processedText = processText(encodedText);
console.log(processedText);