Contents

UCKeyOutput

Specifies values in key-code-to-character tables in a 'uchr' resource.

Declaration

typealias UCKeyOutput = UInt16

Discussion

The Unicode keyboard-layout ( 'uchr') resource contains the data necessary to map virtual key codes to Unicode character codes for a given keyboard layout. The 'uchr' format consists of a header information section and five key mapping data sections. The UCKeyOutput type is a 16-bit value used in the second key mapping section of a 'uchr' resource to specify values in key-code-to-character tables.

You use a UCKeyOutput value in a key-code-to-character table to represent one of the following: an index to a dead-key state record, an index to a Unicode character sequence, or a single Unicode character.

The interpretation of a UCKeyOutput value depends on bits 15 and 14.

If they are 01 (that is, for values in the range of 0x4000-0x7FFF), then bits 0-13 are an index into the keyStateRecordOffsets field of a structure of type UCKeyStateRecordsIndex , which contains offsets to a separate resource-wide list of dead-key state records.

If they are 10 (that is, for values in the range of 0x8000-0xBFFF), then bits 0-13 are an index into the charSequenceOffsets field of a structure of type UCKeySequenceDataIndex , which contains offsets to a separate resource-wide list of Unicode character sequences. If a UCKeySequenceDataIndex structure is not present in the resource or the index is beyond the end of the list, then the entire value (that is, bits 0-15) is a single Unicode character to emit.

Otherwise (for values in the range of 0x0000-0x3FFF and 0xC000-0xFFFD), bits 0-15 are a single Unicode character, with the exception that a value of 0xFFFE-0xFFFF means no character output (these are invalid Unicode codes).

Most single Unicode characters that are likely to be generated by direct keyboard input are in the range 0x0000-0x33FF or 0xE000-0xFFFD, and so are covered by the single-character cases above. Characters outside this range can still be generated by direct keyboard input, in which case they must be represented as 1-character sequences. The fifth key mapping section of the 'uchr' resource, introduced by the UCKeySequenceDataIndex type, provides for this option.