Search code examples
unicodesapui5

Unicode character "^2" is not showing in sapui5 dialog


I am trying to output a unicode character "²" inside of a sapui5-dialog to create squared-meter but it does not work. It only shows "&#178" instead of the "²". I tried using "&#178", "&#xB2" and "&SUP2" to show the unicode character but I could not get it to work. Is this a bug or did I do something wrong?

What I thought what was weird was that in a xml-fragment "&#xB2" is working but the other two unicodes for "²" did not work. Why is that?

I know that a semi-colon is missing after the "&#xB2" and the others but otherwise it would show a "²" in the post and you wouldn't be able to tell them apart.

This is what my dialog looks like:

dialog

Here some of my code for the creation of the dialog. It is called when a button is pressed.

           let sUnicodeChar = "²";
           let oDialog = new sap.m.Dialog({
                title: "Report",
                content: [
                    new sap.m.HBox({
                        justifyContent: "SpaceBetween",
                        items: [
                            new sap.m.VBox({
                                items: [new sap.m.Text({text: "m" + sUnicodeChar}]
                            })
                        ]
                    })
                ]
            });

            oDialog.open();

Solution

  • Since most IDE's and browsers are unicode compatible these days it is possible to not use the unicode (#&...) and instead just enter "²".