0

I have a text like this in Db:

enter image description here

when above text accessed in angular2application and rendered, it is showing HTML number.

ie. single quote(') is showing as "HTML Number &#039"

Html number reference: http://www.ascii.cl/htmlcodes.htm

I need to convert html number in the above text to normal apostrophe symbol like "I've". Any help will be appreciable.

Khushi
  • 1,759
  • 6
  • 26
  • 45

2 Answers2

0

Can you elaborate your query with a code-snippet?

However, I strongly feel that trying below will resolve your issue:

'I\'ve angular2 application'
Mithun Finidi
  • 201
  • 1
  • 4
0

You can create an object escapedCharacters out of HTML Escaped Characters and than use it like this:

// For the example just a few Symbols
let escapedCharacters = {
      '<': '&#60;',
      '>': '&#62;',
      '"': '&#34;',
      '&': '&#38;',
      '\'': '&#39;'
    },
    str = "I've angular 2 application",
    result = str
      .split('')
      .map(char => escapedCharacters[char] || char)
      .join('');
 
console.log(result);
Yosvel Quintero
  • 18,669
  • 5
  • 37
  • 46