On 12/12/15, Sven Barth <[email protected]> wrote: > Jonas has given me the following as a possible solution: > > === code begin === > > procedure UTF8Delete(var s: UTF8String; StartCharIndex, CharCount: PtrInt); > begin > ... > end; > > > procedure UTF8Delete(var s: String; StartCharIndex, CharCount: PtrInt); > var > orgcp: tsystemcodepage; > tmp: utf8string; > begin > orgcp:=StringCodePage(s); > { change code page without converting the data } > SetStringCodePage(s,CP_UTF8,false); > tmp:=s; > { keep refcount to 1 if it was 1, to avoid unnecessary copies } > s:=''; > UTF8Delete(tmp,StartCharIndex,CharCount); > { same as above } > s:=tmp; > tmp:=''; > SetStringCodePage(s,orgcp,false); > end; > > === code end ===
Which adds extra overhead for the default situation (not disableUtf8RTL). But this may very well be neglectable (I'm far too lazy to test). (Nitpicking: the entire second implementation needs then to be ifdef-ed with IFnDEF NO_CP_RTL, beacuse if that define is true Utf8String equals String) Bart -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
