Why are the square bracket characters displayed wrong?

Question
Why are the square bracket characters (&#91; and &#93;) displayed wrong?

Answer
Most IBM 3270 emulators have some degree of difficulty with these characters. The problem is that there is not a consistent definition of what EBCDIC codes represent them. Hosts may define the square bracket characters as X'BA' and X'BB' (as defined in the IBM Character Set Reference as standard EBCDIC characters), or as X'AD' and X'BD' (which is what the IBM C compilers recognize). In addition, some (but not all) hosts display these characters with a Graphic Escape (GE) sequence. When the host and/or x3270 are misconfigured, the square-bracket characters may be displayed as Ý and ¨.

Host configuration
If you are using ISPF, you may simply need to use the correct terminal translation table. According to the IBM's ISPF Planning and Customizing (SC28-1298), Section 3.11, the correct translation table for displaying square bracket characters is called 3278A.

In VM/CMS, the commands  on and   cause the X'AD', X'BD', X'BA' and X'BB' characters to be displayed with a Graphic Escape (GE) prefix. With  and   in effect, they are displayed without the GE prefix.

x3270 code page
By selecting the correct code page, you can set up the emulator to generate and display the proper codes for the square-bracket characters.

The bracket code page is the default, and is used with hosts that use X'AD' and X'BD' for the square-bracket characters. It can be used if the host displays these characters with or without a GE sequence.

The cp037 code page is for use with hosts that use X'BA' and X'BB' for the square-bracket characters, and do not display these characters with a GE sequence.

Regardless of the code page, the emulator will display GE X'AD' and GE X'BD' as &#91; and &#93;, respectively.

x3270 keymap
Absent a special keymap, when the &#91; and &#93; keys are pressed, the emulator will generate the EBCDIC code according to the current host code page. For example, with code page bracket, the &#91; key will generate X'AD'; with code page cp037, it will generate X'AD'.

Most x3270-family emulators also support a special APL-mode keymap. Typically this keymap translates the &#91; and &#93; keys to the actions Key(apl_bracketleft) and Key(apl_bracketright), which result in GE X'AD' or GE X'BD' being added to the display buffer. See APL support for further details.

Summary
Here is a table which summarizes the combinations of characters generated and displayed in the various modes.