Created
September 12, 2024 18:22
-
-
Save dewomser/b56d4bf60e7274d62818971e0e2c1636 to your computer and use it in GitHub Desktop.
Bashskript Für Mastodon. Nachricht mit Überschrift UTF-8 full-width font
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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"