From 6f2e3b88649543d625b76ac5542dd8838b28f0b1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 12 Feb 2009 02:34:39 -0400 Subject: Properly handle UTF-8 characters in commodity strings. --- src/amount.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/amount.cc') diff --git a/src/amount.cc b/src/amount.cc index 3fb8ddaf..ffeaeea6 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -31,6 +31,7 @@ #include "amount.h" #include "commodity.h" +#include "unistring.h" namespace ledger { @@ -1001,6 +1002,20 @@ void amount_t::print(std::ostream& _out) const _out << out.str(); } +void amount_t::right_justify(std::ostream& out, int width) const +{ + std::ostringstream buf; + buf << *this; + + unistring temp(buf.str()); + + int spacing = width - int(temp.length()); + while (spacing-- > 0) + out << ' '; + + out << temp.extract(); +} + bool amount_t::valid() const { if (quantity) { -- cgit v1.2.3