Example of i18n command
Sometimes command needs to handle characters on multibyte locale not only showing localized messages, but also search or modify them. This means to be required to handle multibyte characters by one by one.
In OHAC core, scsetup and clsetup use text formatting command to fit terminal width because these are actually CUI rather than CLI. Internal command scprt is used this purpose.
Wide character is used for this purpose. Single wide character keeps single character which has few byte length. And wide character functions enable this handling on multibyte locale.
In scprt.c, there are declarations for wide characters variables.
As same as 'char *', 'wchar_t *' can point to strings consistes of wchar_t.
And convert multibyte strings given command line argument to wchar_t strings
by mbstowcs
(here)
Now you can access each wide characters in wthis_line as array.
If you specify wide character array variable with index 0, it shows first single character,
which has actually few bytes length. It can be shown on terminal with '%wc' format
in printf(). The byte length for a one character varies for each
multibyte locales, so we can not assume fixed byte length. This means
we need to use setlocale() function at first in code to notify
runtime locale properly(
here)
Above setlocale() in scprt.c retrieves proper locale environment
variables and is used to enable to handle wchar_t characters based on that locale.
Though code still continues after this, now you can count the number of characters in a line with above operation.
