Chapter 7. Output to Display
65
Concerning the translated messages by
gettext
, the software does not need anything. It works
well if the user properly set LC_CTYPE and LC_MESSAGES locale.
If you are handling a string in non ASCII encoding (using multibyte character, UTF 8 directly,
and so on), you will have to care about points which you don't have to care about if you are using
ASCII.
  8 bit cleanness. I think everyone understand this.
  Continuity of multibyte characters. In multibyte encodings such as EUC JP and UTF 8, one
character may consist from more than two bytes. These bytes should be outputed continued.
Insertion of additional codes between the continuing bytes can break the character. I have
seen a software which outputs location control code everytime it outputs one byte. It breaks
multibyte character.
7.1.2 Number of Columns
Internationalized console software cannot assume that a character always occupy one column.
You can get the number of column of a character of a string using
wcwidth()
and
wcswidth()
.
Note that you have to use
wchar_t
 style programming since these functions have a
wchar_t
parameter.
Additional cares have to be taken not to destroy multicolumn characters. For example, imagine
your software displayed a double column character at (row, column) = (1, 1). What will occur
when your software then display a single column character at (row, column) = (1, 2) or at (1, 1) ?
The single column character erases the half of the double column character? Nobody knows the
answer. It depends on the implementation of the console. All what I can tell is that your software
should avoid such cases.
If your software inputs a string from keyboard, you will have to take more cares. All of numbers
of characters, bytes, and columns differ. For example, in UTF 8 encoding, one character of 'a'
with acute accent occupies two bytes and one column. One character of CJK ideograph occupies
three bytes and two columns. For example, if the user types 'Backspace', how many backspace
code (0x08) should the software outputs? How many bytes should the software erase from the
internal buffer? Don't be nervous; you can use
wchar_t
which assures one character occupy one
wchar_t
everytime and you can use
wcwidth()
to know the number of columns. Note that
control codes such as 'backspace' (0x08) and so on are column oriented everytime. It backs 'one'
column even if the character at the position is a doublewidth character.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

indiana web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved