We are adding support for UTF8 to an existing application with a large code base. This application uses boost::format()
, and the output in non-ASCII characters is not aligning properly. Specifically, when using the %{width}.{length}
s specifier, boost::format()
counts chars, which does not "do the right thing" with utf8 strings. I think it should be possible to change the string length code (which is probably string::size()
) to use utf8len()
or something analogous, based on ... something?
In this case, it is not practical to change the existing code base to use UCS2 (or UCS4, or UTF-16, etc), but it is possible to modify boost::format()
if necessary. I was hoping someone else had run across this need, and can point me to a possible solution.
Note: I found some web pages on using locales with utf8, but most of that seemed more applicable to converting to/from utf8 and UCS4 in streams.