From 026cd6f71a15edd1a242c59d5cb9f8271a108506 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 4 Jun 2012 08:11:36 +0000 Subject: UtfString supports get and append now, but it still needs a lot of work. --- src/unstable/utfstring.cpp | 15 +++++++++++++++ src/unstable/utfstring.h | 2 ++ 2 files changed, 17 insertions(+) (limited to 'src/unstable') diff --git a/src/unstable/utfstring.cpp b/src/unstable/utfstring.cpp index a5d6605..1c6813c 100644 --- a/src/unstable/utfstring.cpp +++ b/src/unstable/utfstring.cpp @@ -11,6 +11,7 @@ #include "bu/stream.h" #include "bu/config.h" #include "bu/sio.h" +#include "bu/membuf.h" using Bu::sio; Bu::UtfString::UtfString() @@ -86,6 +87,13 @@ void Bu::UtfString::append( UtfChar ch ) } } +void Bu::UtfString::append( const UtfString &rSrc ) +{ + aData.append( rSrc.aData ); + iRawLen += rSrc.iRawLen; + iCharLen += rSrc.iCharLen; +} + void Bu::UtfString::setUtf8( const Bu::String &sInput ) { static uint8_t lmask[8] = { @@ -468,6 +476,13 @@ Bu::UtfChar Bu::UtfString::nextChar( int &iIndex ) } } +Bu::String Bu::UtfString::get( Encoding eEnc ) +{ + Bu::MemBuf mb; + write( mb, eEnc ); + return mb.getString(); +} + void Bu::UtfString::debug() { sio << "Raw Utf16: "; diff --git a/src/unstable/utfstring.h b/src/unstable/utfstring.h index 02b015b..af233e8 100644 --- a/src/unstable/utfstring.h +++ b/src/unstable/utfstring.h @@ -107,6 +107,8 @@ namespace Bu */ void append( UtfChar ch ); + void append( const UtfString &rSrc ); + /** * Set the value of the entire string based on the given input and * encoding. The default encoding is Utf8, which is compatible with -- cgit v1.2.3