Skip to content

Instantly share code, notes, and snippets.

@dewomser
Created September 12, 2024 18:22
Show Gist options
  • Save dewomser/b56d4bf60e7274d62818971e0e2c1636 to your computer and use it in GitHub Desktop.
Save dewomser/b56d4bf60e7274d62818971e0e2c1636 to your computer and use it in GitHub Desktop.
Bashskript Für Mastodon. Nachricht mit Überschrift UTF-8 full-width font
#!/bin/bash
# Define the variable
text="Ueberschrift weit"
# Function to convert to full-width
to_fullwidth() {
local input="$1"
local output=""
for (( i=0; i<${#input}; i++ )); do
char="${input:$i:1}"
if [[ "$char" =~ [A-Za-z0-9] ]]; then
# Convert to full-width
char=$(printf "%x" "'$char")
char=$((0x$char + 0xFEE0))
output+=\\u$(printf "%x" "$char")
else
output+="$char"
fi
done
printf "$output"
#| toot post
}
# Convert the text and print the result
fullwidth_text=$(to_fullwidth "$text")
a=$(echo "$fullwidth_text
\nDas ist ein Test
\nnoch eine
\nZeile")
echo -e $a | toot post
@dewomser
Copy link
Author

Funktioniert, aber im Moment nicht benutzt.

Beim Skript hat Copilot mitgeholfen. Er konnte seine eigenen Fehler aber nicht beheben. Dann hab ich das gemacht .

Ausgabe als Mastodonnachricht hinzugefügt.
Um eine Nachricht zu verschicken braucht man "toot"

Bildschirmfoto_20240912_202556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment