Search code examples
c++unicodemfcsuperscript

Superscript 4 not showing up in MFC dialog


So I'm trying to print lbf.S²/in⁴ in a mfc label, but it shows-up as lbf.S²/in4.

I'm wondering why ² will display correctly while wouldn't. It's a 32bit project with Unicode character set.

Here's the .rc code

STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Units"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
    CTEXT           "lbf-sec²/ in⁴",IDC_IPS1,77,36,48,8
END

Solution

  • I'm convinced this has to do with inadvertent changes to the file encoding.

    Recreate as follows:

    1. New dialog based solution.
    2. Paste lbf-sec²/ in⁴ as static text caption
    3. Build and run, and all is well.

      enter image description here enter image description here

    4. Open .rc file in Sublime Text editor and try change encoding to Windows-1252. (This is just to try mimic the inadvertent change that Visual Studio somehow can do.)
    5. Characters are not representable and it falls back to UTF-8 encoding enter image description here
    6. Save
    7. Visual Studio now refreshes and caption is garbled.

      enter image description here

    8. Paste again lbf-sec²/ in⁴ as the label caption
    9. Build and run, and you see the error

      enter image description here

    10. View .rc file in editor and text has indeed reverted and so has encoding

      enter image description here

    Caveat

    I'm not saying I know how, why or when the encoding changes, I'm saying it somehow can happen.

    A solution (What works for me)

    1. Close Visual Studio
    2. Save .rc file still with incorrect lbf-sec²/ in4, and with encoding UTF-8
    3. Open Visual Studio
    4. Edit the caption to the correct lbf-sec²/ in⁴
    5. Use context menu in Resource View to save .rc file (don't know if necessary)
    6. Close dialog editor window (don't know if necessary)
    7. Clean, Rebuild All, run and all is well.

      enter image description here


    If I knew how to clear whatever cache the dialog editor uses, then I'd say that would be closer to the actual solution.