# Legacy encoding “shift_jis” used. Documents must use UTF-8.

> Canonical HTML version: https://rocketvalidator.com/html-validation/legacy-encoding-shift-jis-used-documents-must-use-utf-8
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

All HTML documents must use UTF-8 character encoding. The `shift_jis` encoding is a legacy Japanese encoding that is no longer valid in modern HTML.

The HTML specification requires UTF-8 as the only permitted character encoding for HTML documents. This rule applies regardless of the document's language or the characters it contains. Legacy encodings like `shift_jis`, `euc-jp`, `iso-8859-1`, and others are not allowed.

To fix this, two things need to happen. First, the `<meta>` charset declaration must specify UTF-8. Second, the file itself must actually be saved with UTF-8 encoding. Declaring UTF-8 in the markup while the file is saved as Shift_JIS will cause garbled text (mojibake). Most modern text editors and IDEs (VS Code, Sublime Text, Notepad++) can convert a file's encoding through a "Save with Encoding" or "Reopen with Encoding" option.

If a server sends a `Content-Type` header with `charset=shift_jis`, that header also needs to be updated to `charset=utf-8`. The HTTP header takes precedence over the `<meta>` tag, so fixing only the HTML is not enough if the server overrides it.

## HTML examples

### Before (invalid)

```html
<!doctype html>
<html lang="ja">
  <head>
    <meta charset="shift_jis">
    <title>Example</title>
  </head>
  <body>
    <p>日本語のテキスト</p>
  </body>
</html>
```

### After (valid)

```html
<!doctype html>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <title>Example</title>
  </head>
  <body>
    <p>日本語のテキスト</p>
  </body>
</html>
```

Make sure the file is also saved as UTF-8 in your text editor. In VS Code, click the encoding label in the bottom status bar and select "Save with Encoding" then "UTF-8".
