diff options
author | John Wiegley <johnw@newartisans.com> | 2009-10-25 04:37:46 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-10-25 05:01:47 -0400 |
commit | 5a970554b822d50a6454b8a2e1434e248773adfd (patch) | |
tree | 5cd42dbea4f42ca880fdfb7dafbe237895cc5f91 /src/unistring.h | |
parent | 9b13e77ff5d8cb7ce74c8560364609213a2f8aee (diff) | |
download | fork-ledger-5a970554b822d50a6454b8a2e1434e248773adfd.tar.gz fork-ledger-5a970554b822d50a6454b8a2e1434e248773adfd.tar.bz2 fork-ledger-5a970554b822d50a6454b8a2e1434e248773adfd.zip |
The UTF8 code is now unchecked if --verify is off
Diffstat (limited to 'src/unistring.h')
-rw-r--r-- | src/unistring.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/unistring.h b/src/unistring.h index d3cfc126..268f60e3 100644 --- a/src/unistring.h +++ b/src/unistring.h @@ -70,7 +70,7 @@ public: std::size_t len = input.length(); VERIFY(utf8::is_valid(p, p + len)); - utf8::utf8to32(p, p + len, std::back_inserter(utf32chars)); + utf8::unchecked::utf8to32(p, p + len, std::back_inserter(utf32chars)); } ~unistring() { TRACE_DTOR(unistring); @@ -80,18 +80,22 @@ public: return utf32chars.size(); } - std::string extract(const std::size_t begin = 0, - const std::size_t len = 0) const + std::string extract(const std::string::size_type begin = 0, + const std::string::size_type len = 0) const { - std::string utf8result; - std::size_t this_len = length(); + std::string utf8result; + std::string::size_type this_len = length(); + assert(begin <= this_len); assert(begin + len <= this_len); + if (this_len) - utf8::utf32to8(utf32chars.begin() + begin, - utf32chars.begin() + begin + - (len ? (len > this_len ? this_len : len) : this_len), - std::back_inserter(utf8result)); + utf8::unchecked::utf32to8 + (utf32chars.begin() + begin, + utf32chars.begin() + begin + + (len ? (len > this_len ? this_len : len) : this_len), + std::back_inserter(utf8result)); + return utf8result; } }; |