I am working on creating a Table of Contents for Google slide decks. I have solved many problems, but one slide I found (someone else's) results in a seemingly blank text entry in the Table of Contents. If I copy the entry into NOTEPAD it looks like a square with a question mark in it. I have read in multiple places this is an unprintable character. I would like to include all printable characters in the Table of Contents no matter what language they are in. I also want to preserve things like trademark and copyright symbols. I expect some people will include emojis in their slides but I have not tested that yet. If they pass through visible in the Table of Contents that will be fine.
These are the things I have tried to remove unprintable character(s). My mystery character is getting through.
let beforeTxt = txtBack;
txtBack = beforeTxt.replace(/[^0-9a-z\u0600-\u06FF]/gi, " "); // reserves Arabic characters https://stackoverflow.com/questions/9364400/remove-not-alphanumeric-characters-from-string
if (beforeTxt != txtBack)
console.log("1 + + + + + + + hidden char in text: ; ", beforeTxt);
beforeTxt = txtBack;
txtBack = beforeTxt.replace("/[^0-9a-z\u0600-\u06FF]/gi", " "); // reserves Arabic characters https://stackoverflow.com/questions/9364400/remove-not-alphanumeric-characters-from-string
if (beforeTxt != txtBack)
console.log("2 + + + + + + + hidden char in text: ; ", beforeTxt);
beforeTxt = txtBack;
txtBack = beforeTxt.replace("[^\x00-\x7F]/", " "); // replace unprintable char with space
if (beforeTxt != txtBack)
console.log("3 + + + + + + + hidden char in text: ; ", beforeTxt);
beforeTxt = txtBack;
txtBack = beforeTxt.replace("[^\x00-\x7F]/", "gi", " "); // replace unprintable char with space
if (beforeTxt != txtBack)
console.log("4 + + + + + + + hidden char in text: ; ", beforeTxt);
beforeTxt = txtBack;
// this invisible character looks like a question mark in a box if copied into notepad
txtBack = beforeTxt.replace("", " "); // replace unprintable char with space
if (beforeTxt != txtBack)
console.log("5 + + + + + + + hidden char in text: ; ", beforeTxt);
Am I doing this incorrectly? There is no limit to the number of silly things people might include on slides. The thing I want is for the text in the Table of Contents to be visible.