ORawByteString - The RawByteString replacement for ARC Delphi)

Latest Version

0.4 (beta) (2014/04/16)

Basic info

Do you want to use 8-bit strings on mobile platforms with all the nice old-fashioned features?

ORawByteString has been designed to make old code easily portable to mobile platforms - you only have to rename functions like "Copy" to "AnsiCopy", that's all.

With ORawByteString you can write code like this:
procedure TestAnsiString(const aOutputLines: TStrings);
var
  Raw: RawByteString;
  Wide: string;
  I: Integer;
  C: PAnsiChar;
begin
  Raw := RawByteString('HEADET');
  Raw[AnsiLength(Raw)] := AnsiChar('R');
  Wide := UTF8ToString(Raw);

  aOutputLines.Clear;
  aOutputLines.Add(Wide);

  Raw := RawByteString(Wide);
  I := Pos('H', Raw);
  Raw := AnsiCopy(Raw, I, 3);
  Wide := String(Raw);

  C := PAnsiChar(Raw);
  Raw := RawByteString(C);

  C := PAnsiChar(Raw);
  aOutputLines.Add(String(C[2]));

  AnsiDelete(Raw, 1, 1);
  AnsiInsert(RawByteString('x'), Raw, 2);
  Raw := UpperCase(Raw);
  aOutputLines.Add(String(Raw));
  Raw := LowerCase(Raw);
  aOutputLines.Add(String(Raw));
end;

ORawByteString.pas allows you to:

  • use 8-bit AnsiString and RawByteString on mobile platforms.
  • use 8-bit PAnsiChar on mobile platforms.
  • use 8-bit AnsiChar on mobile platforms.
  • use the same AnsiString code on desktop and mobile.
  • -> no IDE hacking is needed :)
It features it's own text functions like AnsiInsert(), AnsiCopy(), AnsiDelete(), AnsiLength(), Pos(), LowerCase() etc. to offer maximum performance.

And when we talk about performance: ORawByteString is in some scenarios a little bit slower than string on mobile platforms, but most of the test cases and an usual usage showed no significant performance drawbacks. String operations perform on ORawByteString as fast as on string.

ORawByteString features full copy-on-write, mutability and all string features you have always taken advantage of.

On the one hand ORawByteString is a technical exhibition on how you can use records with operators to create your own delphi type, but on the other hand it can also be useful since it's not certain that 8-bit strings will be officially available on mobile platforms at some point.

License

  Author:
    Ondrej Pokorny, http://www.kluug.net

  License:
    MPL 1.1: http://www.mozilla.org/MPL/1.1/

Download

Please be sure you check the license information before downloading any of the files below.

Contact me for more information (you can write in czech/english/german/russian): Email