Special character codes are displayed in the Terminal for diacritics when connecting to an Ubuntu Server

The LC_ALL variable having an empty value was causing the problem.

So the solution of this problem can be found on SO here:

On mac, the LC_ALL variable is not set by default. So writing:

export LC_ALL=en_US.UTF-8  

in your ~/.bash_profile fixes the problem. I assume that You have a default SSH config that has LC_* in the SendEnv configuration.