When using Ubuntu, you may encounter garbled text in certain situations. This can happen in terminal output, when displaying Japanese file names, or while browsing Japanese web pages, depending on your environment. In many cases, Japanese may not display correctly with the default settings, requiring proper configuration. In this article, we will explain the causes of garbled text in Ubuntu and provide concrete solutions to fix it. This guide is intended for:
Ubuntu beginners who have not yet set up Japanese display settings
Users looking to understand the root causes of garbled text and find fundamental solutions
Users experiencing garbled text in terminal or GUI environments and wanting to know how to fix it
Let’s start by examining the main causes of garbled text in Ubuntu.
2. Main Causes of Garbled Text
Incorrect Locale Settings
Locales in Ubuntu define system language and date formatting settings. If these are not properly configured, Japanese text may not display correctly, leading to garbled characters. For example, if you run the locale command and see “C” or “POSIX” in the output, your locale settings may be incorrect:
$ locale
LANG=C
LC_ALL=
Ideally, for a Japanese environment, it should be set to LANG=ja_JP.UTF-8.
Missing or Insufficient Fonts
By default, Ubuntu may not have Japanese fonts installed. As a result, Japanese text may not render properly and instead display as square boxes (□) or random symbols. Font issues can be identified in the following cases:
Garbled text appears in menus and buttons of GUI applications
Japanese text in a text editor appears garbled
Character Encoding Mismatch
While Ubuntu primarily uses UTF-8 as its standard encoding, opening files encoded in Shift_JIS or EUC-JP from external sources may cause garbled text. For instance, opening a file created in a Windows environment on Ubuntu may result in the following:
Unreadable characters when opened in a text editor
Distorted text when using the cat command in the terminal
Misconfigured Terminal or Editor Settings
Even if a file is encoded in UTF-8, improper terminal or editor settings may prevent proper text rendering.
The terminal encoding is set to something other than UTF-8
Text editors like Vim or VSCode fail to auto-detect the correct encoding
Japanese characters appear as “?” or “◇” when displayed with less or cat
3. Checking and Fixing Locale Settings
How to Check Your Locale Settings
To check your current locale settings, run the following command:
To apply the settings, log out and log back in or restart your system.
4. Installing and Configuring Fonts
Why Japanese Fonts Are Necessary
By default, Ubuntu may not have Japanese fonts installed. This can result in improperly displayed Japanese text, appearing as square boxes (□) or unreadable symbols. Font-related issues can be observed in the following cases:
Menus and buttons in GUI applications appear garbled
Japanese text in a text editor displays incorrectly
Recommended Japanese Fonts
Here are some recommended Japanese fonts for Ubuntu:
Font Name
Features
Noto Sans CJK JP
A high-quality Japanese font provided by Google (recommended as the default)
Takao Fonts
Previously the default font for Ubuntu (available in thin and bold versions)
IPA Fonts
High-quality fonts provided by the Information-technology Promotion Agency (IPA)
VL Gothic
Highly readable and optimized for terminal use
How to Install Fonts
1. Install Noto Sans CJK JP (Recommended Default Font)
In this article, we covered Ubuntu’s garbled text issues, their causes, and how to fix them. The primary causes of garbled text include incorrect locale settings, missing fonts, character encoding mismatches, and misconfigured terminal/editor settings.
Key Takeaways
Set the correct locale: Run update-locale LANG=ja_JP.UTF-8
Install Japanese fonts: Use sudo apt install -y fonts-noto-cjk fonts-ipafont
Verify file encoding: Use file -i and convert with iconv
Configure terminal and editors: Ensure UTF-8 encoding settings are applied
By following these steps, you can resolve and prevent garbled text issues in Ubuntu.