summaryrefslogtreecommitdiff
path: root/src/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-12 02:34:39 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-12 02:34:39 -0400
commit6f2e3b88649543d625b76ac5542dd8838b28f0b1 (patch)
treeaf76d46718d4b2b3e51c05c3c53a09987505f02f /src/amount.cc
parent9c9320bc586bc80922921945bfe6bb704c36c624 (diff)
downloadfork-ledger-6f2e3b88649543d625b76ac5542dd8838b28f0b1.tar.gz
fork-ledger-6f2e3b88649543d625b76ac5542dd8838b28f0b1.tar.bz2
fork-ledger-6f2e3b88649543d625b76ac5542dd8838b28f0b1.zip
Properly handle UTF-8 characters in commodity strings.
Diffstat (limited to 'src/amount.cc')
-rw-r--r--src/amount.cc15
1 files changed, 15 insertions, 0 deletions
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) {