'How can I store a block of text with links in my DB? [closed]

I have a textarea (as a description), I want to store the HTML code of the textarea in my db and I can convert the text to HTML with the "br" and "a" tags, the only ones I need. My problem is with the links that have &.

With JS, I tried to use btoa() method to encode the string, store it in my DB and decode with atob() when I want to show it but it gives me this error: Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.



Solution 1:[1]

I resolved the problem with a string replace before inserting it in the table, and where I want to show, replace it again by &.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cristik