summaryrefslogtreecommitdiff
path: root/src/unistring.h
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2014-02-24 14:17:57 -0700
committerCraig Earls <enderw88@gmail.com>2014-02-24 14:17:57 -0700
commit0b4ce5698622eb361e702825b187ebfceb970789 (patch)
treec892d4d8aae61bcbf0d071867be5697b75a5ddbb /src/unistring.h
parentbb8e000d5b35fc4a42c61cf92037674c09d996ca (diff)
parentbc08eed3cb1bdb4f67d1b77273f3254d0cf13be2 (diff)
downloadfork-ledger-0b4ce5698622eb361e702825b187ebfceb970789.tar.gz
fork-ledger-0b4ce5698622eb361e702825b187ebfceb970789.tar.bz2
fork-ledger-0b4ce5698622eb361e702825b187ebfceb970789.zip
Merge commit 'bc08eed3cb1bdb4f67d1b77273f3254d0cf13be2'
Diffstat (limited to 'src/unistring.h')
-rw-r--r--src/unistring.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/unistring.h b/src/unistring.h
index 8e963f37..340115eb 100644
--- a/src/unistring.h
+++ b/src/unistring.h
@@ -44,6 +44,8 @@
namespace ledger {
+int mk_wcwidth(boost::uint32_t ucs);
+
/**
* @class unistring
*
@@ -81,6 +83,14 @@ public:
return utf32chars.size();
}
+ std::size_t width() const {
+ std::size_t width = 0;
+ foreach (const boost::uint32_t& ch, utf32chars) {
+ width += mk_wcwidth(ch);
+ }
+ return width;
+ }
+
std::string extract(const std::string::size_type begin = 0,
const std::string::size_type len = 0) const
{
@@ -133,7 +143,7 @@ inline void justify(std::ostream& out,
unistring temp(str);
- int spacing = width - int(temp.length());
+ int spacing = width - int(temp.width());
while (spacing-- > 0)
out << ' ';