DEV Community

Paweł bbkr Pabian
Paweł bbkr Pabian

Posted on • Edited on

2

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.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (1)

Collapse
 
handyman profile image
Nik Handyman

Great find, thank you for sharing

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay