An API I'm using is sending a message that contains an escaped Unicode character like below and can't get this to print out to the screen correctly.
message: "\ud83d\udc4d hello"
I've tried using the innerHTML method, but it just prints everything as a string.
<div class="comment-content" [innerHTML]="c.message"></div>
Is there a way to unescape this so it can be displayed in the view correctly?
edit I've created a pipe for this and tried encoding/ escaping it along with bypassing Security with DomSanitizer.
import { Pipe, PipeTransform } from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';
@Pipe({
name: 'safeHTml'
})
export class UnicodePipe implements PipeTransform {
constructor(private sanitized: DomSanitizer) {
}
transform(value: any, args?: any): any {
return this.sanitized.bypassSecurityTrustHtml(unescape(encodeURIComponent(value));
}
}