< Previous PageNext Page > Hide TOC

Specification for 'uchr'

The Unicode keyboard-layout ('uchr') resource contains the data necessary to map virtual key codes to Unicode character codes for a given keyboard layout. Each installed script system has one or more keyboard-layout resources, which may be of type 'uchr' or 'KCHR' (an older, non-Unicode keyboard-layout format). There may be one or more keyboard-layout resources for each language or region, depending upon the preference of the user.

The 'uchr' resource ID is determined as for the 'KCHR' resource, with one exception. That is, typically the resource ID for each Unicode keyboard-layout resource is within the range of resource ID numbers for its script system. The ID number of the default keyboard-layout resource for a script system is specified in the itlbKeys field of the script’s international bundle ('itlb') resource. The exception to this is that if a given 'uchr' resource specifies any Unicode characters that are not within the range of a single Mac OS encoding (or are not in any Mac OS encoding), then you must use a negative number for the resource.

For a given resource ID, the system may contain a 'KCHR' resource, a 'uchr' resource, or both. If both a 'KCHR' resource and a 'uchr' resource are present, they must have the same ID, and the 'uchr' resource should match the behavior of the 'KCHR' resource. The keyboard menu shows each keyboard layout as a single entry, regardless of whether it is specified by a 'KCHR', a 'uchr', or both.

Note: The 'uchr' resource contains offsets to tables that may be in any order. A 'uchr' resource may be created in any data-description language that allows the specification of arbitrary binary data.

Unicode Keyboard-Layout Resource Format

The 'uchr' format consists of a header information section and five key mapping data sections, as shown in Figure A-1.


Figure A-1  Overview of a 'uchr' resource

Overview of a 'uchr' resource

The header section of a compiled 'uchr' resource contains a structure of type UCKeyboardLayout and an optional structure of type UCKeyLayoutFeatureInfo. See for an illustration of this section.


Figure A-2  'uchr' resource header

'uchr' resource header

The elements in the header section of a 'uchr' resource are

There may be a variable number of each of the following 'uchr' key mapping sections.

The first key mapping section contains a structure of type UCKeyModifiersToTableNum, which maps a modifier key combination to a particular key-code-to-character table number; and alignment bytes. There may be multiple instances of this entire key mapping section. See Figure A-3 for an illustration of this section.


Figure A-3  'uchr' modifier combination to key-code-to-character table number map

'uchr' modifier combination to key-code-to-character table number map

The elements in the first key mapping section of a 'uchr' resource are

The second key mapping section contains a structure of type UCKeyToCharTableIndex; the list of key-code-to-character tables, each of which maps a virtual key code to a 16-bit UCKeyOutput value; and alignment bytes. There may be multiple instances of this entire key mapping section. See Figure A-4 for an illustration of this section.


Figure A-4  'uchr' key-code-to-character tables

'uchr' key-code-to-character tables

The elements in the second key mapping section of a 'uchr' resource are

The third key mapping section is a map to dead-key state records. It contains a structure of type UCKeyStateRecordsIndex, which is an index to UCKeyStateRecord structures; a variable number of dead-key state records of type UCKeyStateRecord; and alignment bytes. There may be multiple instances of this entire key mapping section (or 0; this section need not be present if no UCKeyOutput value refers to a dead-key state record). See Figure A-5 for an illustration of this section.


Figure A-5  'uchr' dead-key state records

'uchr' dead-key state records

The elements in the third key mapping section of a 'uchr' resource are

Immediately following the UCKeyStateRecordsIndex structure are a variable number of values of type UCKeyStateRecord. Any keycode-modifier combination which initiates a dead-key state or which is a valid terminator of a dead-key state refers to one of these records. However, these records also permit more complex dead-key state processing, such as a series of transitions from one dead-key state directly into another in which each transition can emit a sequence of one or more Unicode characters. Each record contains

The fourth key mapping section contains a structure of type UCKeyStateTerminators and alignment bytes. This is an optional list of default terminators (characters or sequences) for each state; if this table is not present or does not extend far enough to have a terminator for the state, nothing is output when the state terminates. There may be multiple (or 0) instances of this entire key mapping section. See Figure A-6 for an illustration of this section.


Figure A-6  'uchr' default dead-key state terminators

'uchr' default dead-key state terminators

The elements in the fourth key mapping section of a 'uchr' resource are

The fifth key mapping section of the resource is an optional list of character sequences; it contains a structure of type UCKeySequenceDataIndex and Unicode character sequences. This permits a single keypress to generate a sequence of characters, or to generate a single character outside the range that can be represented directly by a UCKeyOutput or UCKeyCharSeq value. There may be multiple (or 0) instances of this entire key mapping section. See Figure A-7 for an illustration of this section.


Figure A-7  'uchr' character key sequences

'uchr' character key sequences

The elements in the fifth key mapping section of a 'uchr' resource are



< Previous PageNext Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-01-10)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.