Fixing PuTTY Character Encoding Issues: Resolving Garbled Text and Double-Drawing in SSH Sessions


3 views

When connecting via PuTTY from Windows 7 to an Ubuntu server, you're experiencing:

  • Corrupted display of special characters (e.g., "â" instead of box-drawing characters "|", "─")
  • Double-rendering of Midnight Commander's selection highlights
  • Character overlap in terminal output

The root cause typically lies in mismatched character encoding between client and server:

# On your Ubuntu server, check current locale settings
locale
# Expected output should include:
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8

Make these adjustments in your PuTTY session configuration:

  1. Window → Translation: Set "Remote character set" to UTF-8
  2. Window → Appearance:
    • Select "Consolas" or "DejaVu Sans Mono" font
    • Enable "Allow selection of variable-pitch fonts"
  3. Terminal → Features:
    • Check "Enable VT100 line drawing even in UTF-8"
    • Check "Disable bidirectional text display"

Ensure proper locale settings on your Ubuntu server:

# Generate locales if missing
sudo locale-gen en_US.UTF-8
# Set system-wide default
sudo update-locale LANG=en_US.UTF-8
# For current session
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

For MC display issues, try these environment variables:

export MC_SKIN=default
export NCURSES_NO_UTF8_ACS=1
alias mc='LANG=en_US.UTF-8 mc -a'

If problems continue:

# Check terminal type is set correctly
echo $TERM
# Should return xterm or xterm-256color
# If not, set it:
export TERM=xterm-256color

# Test UTF-8 support:
echo -e "\xE2\x98\xA0"  # Should display ☠ symbol

For stubborn cases:

  • Try Windows Terminal instead of PuTTY
  • Consider using WSL with native Ubuntu terminal
  • Test with alternative SSH clients like MobaXterm

When connecting via SSH from Windows 7 to Ubuntu servers, PuTTY frequently exhibits character encoding issues that manifest as:

  • Double-rendered UI elements in terminal applications like Midnight Commander
  • Incorrect display of box-drawing characters (showing 'â' instead of '|')
  • Overwritten screen lines during scrolling

The root cause typically lies in mismatched character encoding settings between PuTTY and the remote server:

# On Ubuntu server, verify current locale settings:
locale
# Expected output should include:
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8

# If missing, configure UTF-8 support:
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8

In PuTTY's configuration window (Connection → Data):

  1. Set "Remote character set" to UTF-8
  2. Enable "Treat CJK ambiguous characters as wide"
  3. Under Terminal → Features:
    • Check "Disable bidirectional text display"
    • Enable "Enable VT100 line drawing even in UTF-8"

Sometimes the issue stems from incorrect TERM environment variable:

# On Ubuntu server, check current TERM setting:
echo $TERM

# For best compatibility with PuTTY:
export TERM=xterm-256color
# Add to ~/.bashrc for persistence:
echo 'export TERM=xterm-256color' >> ~/.bashrc

For persistent rendering issues, try these registry edits (backup first):

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings]
"LineCodePage"="UTF-8"
"UTF8Override"=dword:00000001
"Font"="Consolas"
"FontHeight"=dword:0000000c
"FontCharSet"=dword:00000000
"FontQuality"=dword:00000002

Verify your setup with these test patterns:

# Box-drawing test:
echo -e "\xE2\x94\x8C\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x90"
echo -e "\xE2\x94\x82   \xE2\x94\x82"
echo -e "\xE2\x94\x94\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x98"

# Should display:
┌───┐
│   │
└───┘