1

The value "\1014" is coming from my database and I want to display it in an ExtJS Panel.

The problem is, it gets processed as an entity value, and "A4" is displayed instead

I don't want to have to do entity encoding on the back end.

I tried

Ext.util.Format.htmlEncode('\1014')

But this also returns "A4"

What is the correct way to encode such values on the front-end for display?

Black
  • 5,023
  • 6
  • 63
  • 92

2 Answers2

0

This has nothing to do with ExtJS. This is a builtin feature of JavaScript and JSON. If you want to send the non-literal \101 as JSON to the frontend, you have to escape the backslash correctly to the specs in the backend:

{"success":true,"data":{"test":"\\101","id":"extModel2-1"}}

If you don't escape the backslash, it will be converted to the appropriate literal immediately when it hits the frontend and is then indistinguishable from the letter A, so this is not revertible on the frontend.

Relevant fiddle

Relevant older answer

Alexander
  • 19,906
  • 19
  • 75
  • 162
0

You can parse data using JSON.parse(response.reponseText) instead of Ext.decode

PraveenKumar S
  • 260
  • 1
  • 13