Dealing with code conversions can be tricky. I am currently working on a project where I need to convert certain codes to their respective symbols. However, I have encountered some issues with the conversion process.
For example, when trying to convert apostrophe code to an actual apostrophe symbol, it works fine. But when dealing with double quotes code or ampersand code, the conversion does not seem to be working as expected. Here is the snippet of code that I have written so far:
let txt = 'Test"Name';
let txt2 = 'Test'Name';
txt = this.sanitizer.sanitize( SecurityContext.HTML, txt );
txt2 = this.sanitizer.sanitize( SecurityContext.HTML, txt2 );
const ul = this.renderer.createElement('ul');
const li = this.renderer.createElement('li');
const li2 = this.renderer.createElement('li');
const text = this.renderer.createText(txt);
const text2 = this.renderer.createText(txt2);
this.renderer.appendChild(li, text);
this.renderer.appendChild(li2, text2);
this.renderer.appendChild(ul, li);
this.renderer.appendChild(ul, li2);
this.renderer.appendChild(this.el.nativeElement, ul);
If you want to take a look at the code in action, check out the Stackblitz here.
Issue 1: Some codes are not being converted to their respective symbols.
Issue 2: Additionally, I have noticed that French characters like é are getting converted to code instead of showing the actual character (Updated the Stackblitz to demonstrate).