# JIS encoding

In computing, JIS encoding refers to several Japanese Industrial Standards for encoding the Japanese language. Strictly speaking, the term means either:
* A set of standard coded character sets for Japanese, notably:
** JIS X 0201, the Japanese version of ISO 646 (ASCII) containing the base 7-bit ASCII characters (with some modifications) and 64 half-width katakana characters.
** JIS X 0208, the most common kanji character set containing 6,879 characters, including 6,355 kanji and 524 other characters (one 94 by 94 plane)
** JIS X 0212, a supplement for JIS X 0208 which adds 5,801 kanji, totaling 12,156 kanji (a second 94 by 94 plane)
** JIS X 0213, which extends JIS X 0208 (two planes)
* JIS X 0202 (also known as ISO-2022-JP), a set of encoding mechanisms for sending JIS character data over transmission media that only support 7-bit data.
In practice, "JIS encoding" usually refers to JIS X 0208 character data encoded with JIS X 0202. For instance, the IANA uses the JIS_Encoding label to refer to JIS X 0202, and the ISO-2022-JP label to refer to the profile thereof defined by RFC 1468.
Other encoding mechanisms for JIS characters include the Shift JIS encoding and EUC-JP. Shift JIS adds the kanji, full-width hiragana and full-width katakana from JIS X 0208 to JIS X 0201 in a backward compatible way. Shift JIS is perhaps the most widely used encoding in Japan, as the compatibility with the single-byte JIS X 0201 character set made it possible for electronic equipment manufacturers (such as cash register manufacturers) to offer an upgrade from older cheaper equipment that was not capable of displaying kanji to newer equipment while retaining character-set compatibility.
EUC-JP is used on UNIX systems, where the JIS encodings are incompatible with POSIX standards.
A more recent alternative to JIS coded characters is Unicode (UCS coded characters), particularly in the UTF-8 encoding mechanism.

## Encoding comparison

The following table compares the features of the three main encoding schemes for JIS X 0208.
| Encoding | Alternate name | 7-bit? | ISO 2022? | State­less? | Accepts ASCII? | 0x00–7F always ASCII? | Superset of 8-bit JIS X 0201? | Supports JIS X 0212? | Bytewise self-synchron­izing? | Bitwise self-synchron­izing? |
| ISO-2022-JP | "JIS" (JIS X 0202) | Yes | Yes | No | Yes | Sequences can be non-ASCII | No (encoding possible) | Possible | No | No |
| Shift_JIS | "SJIS" | No | No | Yes | Almost | Isolated bytes can be non-ASCII | Yes | No | No | No |
| EUC-JP | "UJIS" (Unixized JIS) | No | Yes | Yes | Usually | Yes | No (encoded) | Usually available | No | No |
| Unicode formats for comparison |||||||||||
| UTF-8 | | No | No | Yes | Yes | Yes | No (encoded) | Available | Yes | Usually |
| UTF-16 | "Unicode" | No | No | Yes | No | No | No (encoded) | Available | Over 16-bit words only. | No |
| GB 18030 | | No | No | Yes | Yes | Isolated bytes can be non-ASCII | No (encoded) | Available | No | No |
| UTF-32 | | No | No | Yes | No | No | No (encoded) | Available | Usually, in practice | No |
* ↑ i.e. does not require 8-bit clean transmission.
* ↑ i.e. the sequence used to encode a given character is always the same, no matter what the previous character(s) were. See state (computer science).
* 1 2 ISO-2022-JP is a stateful encoding: all charsets are encoded over 0x21–7E and are switched between using ANSI escapes. Hence, while it is ASCII in its initial state, entire sequences of non-ASCII characters can be encoded with ASCII bytes.
* ↑ JIS X 0201 katakana are available in JIS X 0202 and ISO 2022, but not included in the basic ISO-2022-JP profile, although they are a common extension.
* ↑ JIS X 0212 is available in JIS X 0202 and ISO 2022, and included in the ISO-2022-JP-1 and ISO-2022-JP-2 profiles, but not in the basic ISO-2022-JP profile.
* ↑ Single byte characters 0x21–7E in Shift_JIS are properly ISO-646-JP, in order to be a superset of 8-bit JIS X 0201, but are often decoded (not necessarily displayed) as ASCII, which differs only in two places.
* ↑ Some (not all) ASCII bytes can appear as second bytes, but not first bytes, of double-byte characters in Shift_JIS. Hence in a sequence of two or more ASCII bytes, the second byte onward are necessarily ASCII (or ISO-646-JP) characters.
* 1 2 Packed-format EUC is based on ISO 2022 mechanisms, with charset designations pre-arranged. Charset designation escapes and locking shifts are avoided, whereas use of single shifts can be implemented in a non-stateful manner. The constraints of ISO 2022 are nonetheless followed.
* ↑ Single byte characters 0x21–7E in EUC-JP are generally considered ASCII, but sometimes treated as ISO-646-JP.
* ↑ Unlike Shift_JIS, EUC-JP will not handle plain 8-bit JIS X 0201 input without prior conversion, due to the different representation of the JIS X 0201 katakana (with single-shifts).
* ↑ JIS X 0212 in EUC-JP is not always implemented.
* ↑ Besides the properties of the encodings themselves, Unicode formats have further advantages stemming from the underlying character set: they are not limited to JIS coded characters but can represent the entirety of UCS (including the full repertoire of JIS coded characters), and are hence suited to international use. They are also less badly affected by colliding proprietary extensions, due to their greater base repertoire and designated private use areas.
* ↑ Most bitwise frameshifts of UTF-8-encoded text will produce invalid UTF-8, but it is possible to construct sequences of characters that remain valid UTF-8 even when frameshifted by one or more bits.
* ↑ By Microsoft only.
* ↑ While GB 18030 and GBK are extensions of the EUC-CN form of GB/T 2312, they do not follow the constraints of EUC or ISO 2022, unlike EUC-JP (or the original EUC-CN).
* ↑ Although, in theory, UTF-32 is self-synchronizing over 32-bit dwords only, the use of a 32-bit value to represent a 21-bit value means that, in practice, UTF-32 contains a continuous run of at least 11 zero bits at the high end of each character, which can usually be used to align to character boundaries, depending on the codepoint(s) involved.