Boost logo

Boost :

From: Karl Nelson (kenelson_at_[hidden])
Date: 2000-08-18 23:37:22


Hello,

With the recent conversion of gtk+ to UTF-8 for i18n issues,
I have been writing some classes to assist in use of C++ libraries.
(As I am the maintainer of Gtk-- the C++ bindings for gtk+.)
The issue specifically is that streams do not work well for i18n.

Streams have a bad tendency to cause pieces by breaking up text.
This presents a problem for translation as phrases often
must be translated as one unit with gettext. Further, the use of a
stream fixes the order of which variables will be displayed which
makes translation extremely awkward for languages where the order
does not match that of the original program. As a result most codes
which are designed for i18n can't use streams.

One solution is to use sprintf or ostream.form(). However, both
depend on the use of ellipsis which will not accept C++ types. Thus
for many C++ types, this means placing implementing the
print function separately whereever it is used or writting
conversion functions to take types to strings for purposes
of sending to printf. Unix 98 printf includes ablity to
reorder arguments but that still doesn't help C++.

An alternative is to create a manipulator which functions like
printf allowing strings to be translated to be placed as
one group and at the same time allow arbrary rearrangements of
the stream arguments. Such a manipulator would replace the
ellipsis with stream operations which can be overloaded in the usual
fashion, but the operations would be proxied so that they could
be directed to another stream buffer which spools up rearranges
the text. This would implement the Unix 98 printf specifications
as closely as streams allow.

I have implemented a first cut at such a manipulator. It still
has a number of issues both in implementation and form which
would prevent it from being included in boost at this time. However,
I would like to get some comments reviewing it so that the final
implementation is acceptable. It is fairly heavily documented
with design notes describing defects and functionality. Assuming
that it is of interest to boost and reviews give enough information
on how to get the class in shape, I can polish the class for
inclusion.

Source of class available at
  http://www.ece.ucdavis.edu/~kenelson/ofrstream.cc

Thanks

--Karl Einar Nelson


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk