MIME / IANA | Shift_JIS |
---|---|
Alias(es) | MS_Kanji,[1] PCK[2][3] |
Language(s) | PrimarilyJapanese, but also supportingEnglish,Russian,Bulgarian,Greek |
Standard | JIS X 0208:1997 Appendix 1 |
Classification | ExtendedISO 646,[a]variable-width encoding,CJK encoding |
Extends | JIS X 0201 8-bit format |
Transforms / Encodes | JIS X 0208 |
Succeeded by | Shift_JIS-2004 (JIS) Windows-31J (web) |
Shift JIS (alsoSJIS,MIME nameShift_JIS, known asPCK inSolaris contexts)[2][3] is acharacter encoding for theJapanese language, originally developed by theJapanese companyASCII Corporation[b] in conjunction withMicrosoft and standardized asJIS X 0208 Appendix 1.
Shift JIS is based on character sets defined withinJIS standardsJIS X 0201:1997 (for thesingle-byte characters) andJIS X 0208:1997 (for thedouble-byte characters).
As of January 2025[update], less than 0.05% of surveyed web pages used Shift JIS (actually decoded as its supersetWindows-31J encoding), a decline from 1.3% in July 2014.[4] Shift JIS is the third-most declared character encoding for Japanese websites (though in effect it means its supersetWindows-31J is used, so it is third-most popular), declared by 1.0% of sites in the .jp domain, whileUTF-8 is used by 99% of Japanese websites.[5][6]
Shift JIS is also sometimes used inQR codes (they are a Japanese invention also allowing UTF-8, which may though be preferred use).[7][8]
Shift JIS is an extension of the single-byte encodingJIS X 0201:1997, that uses unassigned code points inJIS X 0201 to encode the double-byteJIS X 0208:1997 character set. The lead bytes for the double-byte characters are "shifted" around the 64 halfwidthkatakana characters in the single-byte range0xA1 to 0xDF.
The single-byte characters0x00 to 0x7F match theASCII encoding, except for ayen sign (U+00A5) at 0x5C and anoverline (U+203E) at 0x7E in place of the ASCII character set's backslash and tilde respectively (these deviations from ASCII align withJIS X 0201). The single-byte characters from 0xA1 to 0xDF map to the half-width katakana characters found inJIS X 0201.
For double-byte characters, the first byte is always in the range 0x81 to 0x9F or the range 0xE0 to 0xEF (these ranges are unassigned inJIS X 0201). If the first byte is odd, the second byte must be in the range 0x40 to 0x9E (but cannot be 0x7F); if the first byte is even, the second byte must in the range 0x9F to 0xFC.
Shift JIS only guarantees that the first byte of two-byte characters will be high-bit-set (0x80–0xFF); the value of the second byte can be either high or low. The appearance of byte values 0x40–0x7E as second bytes ofcode words makes reliable Shift JIS detection difficult, because the same codes are used for ASCII characters. Since the same byte value can be either first or second byte, string searches are difficult, since simple searches can match the second byte of a character and the first byte of the next, which is not a valid Shift JIS character.String-searching algorithms must be tailor-made forShift JIS.
Shift JIS is fullybackwards compatible with theJIS X 0201single-byte encoding, meaning that any validJIS X 0201 string is also a valid Shift JIS string.
Double-byte characters inJIS X 0208 need to be transformed in order to be encoded in Shift JIS. For a double-byte JIS X 0208 sequence,[c] the transformation to the corresponding Shift JIS bytes is:
The competing 8-bit formatEUC-JP, which does not support single-byte halfwidth katakana, allows for a cleaner and more direct conversion to and from JIS X 0208code points, as all high-bit-set bytes are parts of a double-byte character and all codes from ASCII range represent single-byte characters.
HTML written in Shift JIS can still be interpreted to some extent when incorrectly tagged as ASCII, and when the charset tag is in the top of the document itself, since the important start and end of HTML tags and fields (<
,>
,/
,"
,&
,;
) are encoded as the same bytes as in ASCII, and those bytes do not appear in two-byte sequences.
Shift JIS can be used instring literals in programming languages such asC, but a few things must be taken into consideration. Firstly, that theescape character 0x5C, normallybackslash, is thehalf-widthyen sign (¥) in Shift JIS. If the programmer is aware of this, it would be possible to useprintf("ハローワールド¥n");
(where ハローワールド isHello, world and ¥n is an escape sequence), assuming the I/O system supportsShift JIS output. Secondly, the 0x5C byte will cause problems when it appears as second byte of a two-byte character, because it will be interpreted as an escape sequence, which will mess up the interpretation, unless followed by another 0x5C.
Many different versions of Shift JIS exist. There are two areas for expansion:
Firstly, JIS X 0208 does not fill the whole 94×94 space encoded for it in Shift JIS, therefore there is room for more characters here—these are really extensions to JIS X 0208 rather than to Shift JIS itself.
Secondly, Shift JIS has more encoding space than is needed forJIS X 0201 andJIS X 0208 (see§ Shift JIS byte map below), and this space can and is used for yet more characters (as either single-byte or double-byte characters).
The most popular extension isWindows code page 932 (aCCSID also used forIBM's extension to Shift JIS), which is registered with theIANA as "Windows-31J",[1] separately from Shift JIS. This was popularized by Microsoft, although Microsoft itself does not recognize the Windows-31J name and instead calls that variation "shift_jis".[9][10] IBM's code page 943 includes the same double-byte codes as Microsoft's code page 932, while IBM's code page 932 includes fewer extensions (excluding those which Microsoft incorporates from NEC), and retains the character order from the 1978 edition of JIS X 0208, rather than implementing thecharacter variant swaps from the 1983 standard.[11]
Windows-31J assigns 0x5C to U+005C REVERSE SOLIDUS (thebackslash), and 0x7E to U+007ETILDE, followingUS-ASCII.[12] However, most localised fonts on Windows display U+005C as aYen sign forJIS X 0201 compatibility.[13][14] It includes several extensions, namely "NEC special characters (Row 13), NEC selection of IBM extensions (Rows 89 to 92), and IBM extensions (Rows 115 to 119)",[1] in addition to setting some encoding space aside forend user definition.[15]
Windows codepage 932 is the version used in theW3C/WHATWG encoding standard used byHTML5, which includes the "formerly proprietary extensions from IBM and NEC" from Windows-31J in its table for JIS X 0208,[16] and also treats the label "shift_jis" interchangeably with "windows-31j" with the intent of being "compatible with deployed content".[17]
The version of Shift-JIS originating from theclassic Mac OS (known asx-mac-japanese
, Code page 10001[9] or MacJapanese) assigned thetilde to 0x7E (followingUS-ASCII, notJIS X 0201 which assigns theoverline here), but theYen sign to 0x5C (as inJIS X 0201 and standardShift JIS). It also extendedJIS X 0201 by assigning thebackslash to 0x80 (corresponding to 0x5C in US-ASCII), thenon-breaking space to 0xA0, thecopyright sign to 0xFD, thetrademark symbol to 0xFE and the half-widthhorizontal ellipsis to 0xFF. It also added extended double byte characters; including 53 vertical presentation forms in theShift_JIS range 0xEB41–0xED96, at 84 JIS rows down from their canonical forms, and 260 special characters in the Shift_JIS range 0x8540–0x886D.[18] This variant was introduced inKanjiTalk version 7.[19]
However, certain Mac OS typefaces used other variants. Sai Mincho and Chu Gothic use a "PostScript" variant of MacJapanese, which included additional vertical presentation forms and a different set of extended special characters, based on theNEC special characters, some of which were only available in the printer versions of the fonts.[18] Older versions of Maru Gothic and Hon Mincho fromSystem 7.1 encoded vertical presentation forms at 10 (not 84) JIS rows down from their canonical forms, and did not include the special character extensions, this was subsequently changed.[18][20] The typical variant used with KanjiTalk version 6 placed the vertical presentation forms 10 rows down, and also used the NEC extension layout for row 13.[21]
Alias(es) | Shift_JISx0213 |
---|---|
Language(s) | Japanese,Ainu,English,Russian |
Standard | JIS X 0213 |
Extends | Shift_JIS (1997), JIS X 0201 (8-bit) |
Transforms / Encodes | JIS X 0213 |
Preceded by | Shift_JIS (1997) |
The newerJIS X 0213 standard defines an extended variant of Shift_JIS referred to asShift_JISx0213 (in a previous version of the standard) orShift_JIS-2004. It is a superset of standard Shift JIS.[22]
In order to represent the allocated rows on both planes of JIS X 0213, Shift_JIS-2004 uses the following method of mapping codepoints.[23]
In the above, is a two-byte Shift_JIS-2004 sequence, is the plane (面,men, surface) number (1 or 2), is the row (区,ku, ward) number (1-94) and is the cell (点,ten, point) number (1-94). Theku andten numbers are equivalent to and respectively, where is a two-byte JIS sequence referencing a given plane.
The same set of characters can be represented byEUC-JIS-2004, the EUC-JP based counterpart.
Some of the additions collide with popular Shift JIS extensions, including Windows codepage 932 which is used in web standards (seeabove). For example, compare plane 1 row 89 inJIS X 0213 (beginning 硃, 硎, 硏...)[24] to row 89 in the JIS X 0208 variant defined in web standards (beginning 纊, 褜, 鍈...).[25] In addition, some of the characters map to Unicode characters beyond the BMP.
The space with lead bytes 0xF5 to 0xF9 (beyond the region used for JIS X 0208) is used by Japanesemobile phone operators forpictographs for use inE-mail.[26]KDDI goes further and defines hundreds more in the space with lead bytes 0xF3 and 0xF4.[27]
Beyond even this, there have been numerous minor variations made on Shift JIS, with individual characters here and there altered. Most of these extensions and variants have noIANA registration, so there is much scope for confusion, if the extensions are used.
A variant is the one that must be used if wanting to encode Shift JIS in source codestrings ofC and similar programming languages. This variant doubles the byte 0x5C if it appears as second byte of a two-byte character, but not if it appears as a single "¥" (ASCII: "\") character, because 0x5C is the beginning of anescape sequence. The best way of handling this is a special editor which encodesShift JIS this way.
The chart below gives the detailed meaning of each byte in a stream encoded in standardShift JIS (conforming toJIS X 0208:1997).
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Some of the bytes which are not used for single-byte codes or initial bytes inJIS X 0208:1997 are used by certain extensions, resulting in the layout detailed in the chart below.
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|