I need to use fmt to format some text output in Greek, but it does not behave as it does with latin characters. Consider for example the sentences with 15 characters below.
With latin characters:
$echo "Have a nice day" | fmt -w 16
Have a nice day
but, strangely, with non-latin characters:
$echo "Ηαωε α νιψε δαυ" | fmt -w 16
Ηαωε α
νιψε δαυ
In fact for the above string, the smallest value that it prints the sentence without line breaks would be -w 28:
$echo "Ηαωε α νιψε δαυ" | fmt -w 28
Ηαωε α νιψε δαυ
$echo "Ηαωε α νιψε δαυ" | fmt -w 27
Ηαωε α νιψε
δαυ
Can somebody explain why this happens and how to fix it, if possible?