DEV Community

Paweł bbkr Pabian
Paweł bbkr Pabian

Posted on • Updated on

Fun with UTF-8: Printing sound

"Fun with UTF" are digressions from main posts in this series. They are purely optional and not needed to understand basics of UTF, but showing some cool tricks. Let's start with first one.

I already explained that UTF-8 is ASCII compatible. And ASCII had many control characters, that were literally controlling physical devices like this teletype on the other end:

Teletype

Many of those control characters are obsolete today. Some are still in use, like for example CRLF line ending, made from two control characters Carriage Return (literally moving printing head to the beginning of line) and Line Feed (literally scrolling paper to the next line).

Now try this:

$ raku -e 'Buf.new( 0x07 ).decode.say'
Enter fullscreen mode Exit fullscreen mode

It prints BEL character. Which surprisingly is still supported by many terminals today and will do system alert ping. Back in DOS era (when computers without sound cards were common) it caused a PC speaker beep. And even further back in time it was ringing physical bell (hence the name) to notify that something in incoming transmission required attention.

Top comments (1)

Collapse
 
handyman profile image
Nik Handyman

Great find, thank you for sharing