michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2011-2012, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ******************************************************************************* michael@0: * file name: appendable.cpp michael@0: * encoding: US-ASCII michael@0: * tab size: 8 (not used) michael@0: * indentation:4 michael@0: * michael@0: * created on: 2010dec07 michael@0: * created by: Markus W. Scherer michael@0: */ michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include "unicode/appendable.h" michael@0: #include "unicode/utf16.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: Appendable::~Appendable() {} michael@0: michael@0: UBool michael@0: Appendable::appendCodePoint(UChar32 c) { michael@0: if(c<=0xffff) { michael@0: return appendCodeUnit((UChar)c); michael@0: } else { michael@0: return appendCodeUnit(U16_LEAD(c)) && appendCodeUnit(U16_TRAIL(c)); michael@0: } michael@0: } michael@0: michael@0: UBool michael@0: Appendable::appendString(const UChar *s, int32_t length) { michael@0: if(length<0) { michael@0: UChar c; michael@0: while((c=*s++)!=0) { michael@0: if(!appendCodeUnit(c)) { michael@0: return FALSE; michael@0: } michael@0: } michael@0: } else if(length>0) { michael@0: const UChar *limit=s+length; michael@0: do { michael@0: if(!appendCodeUnit(*s++)) { michael@0: return FALSE; michael@0: } michael@0: } while(s