Terminal control/Unicode output: Difference between revisions
Content added Content deleted
(initial draft) |
|||
Line 2: | Line 2: | ||
The task is to check that the terminal supports Unicode output, before outputting a Unicode character. If the terminal supports Unicode, then the terminal should output a Unicode delta (U+25b3). If the terminal does not support Unicode, then an appropriate error should be raised. |
The task is to check that the terminal supports Unicode output, before outputting a Unicode character. If the terminal supports Unicode, then the terminal should output a Unicode delta (U+25b3). If the terminal does not support Unicode, then an appropriate error should be raised. |
||
=={{header|UNIX Shell}}== |
|||
<lang sh>if |
|||
awk ' |
|||
BEGIN { |
|||
if (ENVIRON["LANG"] ~ "UTF") |
|||
exit 0 # exit ok |
|||
exit 255 # exit false |
|||
}' |
|||
then |
|||
# This terminal supports Unicode |
|||
printf "\u25b3" # Requires a Unicode compatible printf |
|||
else |
|||
echo "HW65001 This program requires a Unicode compatible terminal" >&2 |
|||
exit 252 # Incompatible hardware |
|||
fi</lang> |
|||
{{omit from|BASIC}} |
{{omit from|BASIC}} |
Revision as of 07:05, 11 September 2011
Terminal control/Unicode output is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
The task is to check that the terminal supports Unicode output, before outputting a Unicode character. If the terminal supports Unicode, then the terminal should output a Unicode delta (U+25b3). If the terminal does not support Unicode, then an appropriate error should be raised.
UNIX Shell
<lang sh>if
awk ' BEGIN { if (ENVIRON["LANG"] ~ "UTF") exit 0 # exit ok exit 255 # exit false }'
then
# This terminal supports Unicode printf "\u25b3" # Requires a Unicode compatible printf
else
echo "HW65001 This program requires a Unicode compatible terminal" >&2 exit 252 # Incompatible hardware
fi</lang>