I am printing a formatted table. But sometimes these user generated characters are taking more than one character width and it messes up the formatting as you can see in the screenshot below...
The width of the "title" column is formatted to be 68 bytes. But these "special characters" are taking up more than 1 character width but are only counted as 1 character. This pushes the column past its bounds.
print('{0:16s}{3:<18s}{1:68s}{2:>8n}'.format((
' ' + streamer['user_name'][:12] + '..') if len(streamer['user_name']) > 12 else ' ' + streamer['user_name'],
(streamer['title'].strip()[:62] + '..') if len(streamer['title']) > 62 else streamer['title'].strip(),
streamer['viewer_count'],
(gamesDic[streamer['game_id']][:15] + '..') if len(gamesDic[streamer['game_id']]) > 15 else gamesDic[streamer['game_id']]))
Any advice on how to deal with these special characters?
edit: I printed the offending string to file.
( ) ✨ LIVE SUBS GET SNAPCHAT
edit2:
Why do these not align on a character boundary?
edit3:
Today the first two characters are producing weird output. But the columns are aligned in each case below.
First character in isolation...
title[0]
Second character in isolation... title[1]
First and second character together.. title[0] + title[1]