# SYSCONS console driver: garbage characters are printed



## mr123 (Dec 19, 2021)

On a fresh install of FreeBSD-13.0-RELEASE-amd64.vhd, I changed the default console driver to sc by adding `kern.vty=sc` to /boot/loader.conf, followed by a reboot. However, the use of sc results in some garbage characters. For example, the screenshot below shows some garbage characters that appear when I run `man syscons`:






How do I solve the problem?

I noticed that garbage characters are not printed when using vt instead of sc. I need to use sc because I am resizing the console using `vidcontrol`.


----------



## Alain De Vos (Dec 19, 2021)

What is your /boot/loader.conf ?


----------



## mr123 (Dec 19, 2021)

Alain De Vos said:


> What is your /boot/loader.conf ?



There is only one line in it: `kern.vty=sc`.


----------



## ralphbsz (Dec 19, 2021)

What are your locale configurations (LANG, LC, all that)? And what is TERM set to? It looks a little bit like the terminal is trying to display unicode characters in an invalid fashion.


----------



## mr123 (Dec 20, 2021)

ralphbsz said:


> What are your locale configurations (LANG, LC, all that)? And what is TERM set to? It looks a little bit like the terminal is trying to display unicode characters in an invalid fashion.


I didn't make any changes to the locale configurations. As mentioned, I have only made one change to a fresh install of FreeBSD-13.0-RELEASE-amd64.vhd; I added `kern.vty=sc` to /boot/loader.conf.


```
# locale
LANG=C.UTF-8
LC_CTYPE="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_TIME="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_ALL=
```


```
# echo $TERM
xterm
```


```
# echo $MM_CHARSET
UTF-8
```


----------



## T-Daemon (Dec 20, 2021)

mr123 said:


> ```
> # locale
> LANG=C.UTF-8
> ```


syscons(4) doesn't support UTF-8.

Beginning with 13.0 (actually when it was CURRENT, if I'm not mistaken) localization has been set to UTF-8 by login classes method in /etc/login.conf to the `default` login class.

Edit /etc/login.conf, remove or comment UTF-8 lines

```
default:\
        ...
        :charset=UTF-8:\
        :lang=C.UTF-8:
```
Also remove the backslash from `:umask=022:\`, run  `cap_mkdb /etc/login.conf` afterwards. To take effect of the new localization, logged in users must log out and log in.


----------



## ralphbsz (Dec 20, 2021)

Interesting. I actually now suspect that it is something other than UTF-8, namely the handling of escape sequences. Which would be in some strange intertwined with 8-bit support and UTF-8. Here is one possible explanation.

When you do "man foo", the man program by default outputs the result using only very simple formatting, namely overstriking with control H (backspace). So the parts that are boldfaced are detected by the pager, which is usually some version of less. What less does is this: If it sees a boldfaced piece of text (overstrike in the form t^Hte^Hex^Hex^Ht), it removes the overstrikes, and instead outputs the escape sequence for bold face, which is Esc[1m or Csi1m (where Esc = 0x1B and Csi=0x9B). And this is where the problem MIGHT arise: Depending on the setting of Unicode, character set and 8-bit clean (in the terminal settings, visible in stty), less MIGHT try to use the Csi character, which MIGHT confuse the console.

If you have ample time, you could test it, the following way: Create a file that contains text, in a mix of regular and overstrike. Cat the text to the screen, and it should look normal, no errors, no visible overstrike (no backspaces), but also no bold face. Then run the text through less, and you should see bold text. The question is: At the boundary between regular and bold, will everything look normal?


----------



## T-Daemon (Dec 20, 2021)

T-Daemon said:


> Beginning with 13.0 (actually when it was CURRENT, if I'm not mistaken) localization has been set to UTF-8 by login classes method in /etc/login.conf


For those who are interested, here it is, source https://cgit.freebsd.org/src:

Change the default locale to C.UTF-8

Before above was introduced:
Add hybrid C.UTF-8 locale being identical to default C locale ...

Also note "Differential Revision" in the commit comments.


----------

