Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-03

Base36 encoding

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Constantine Yannakopoulos

Hello all.

I need a couple of base36 (https://en.wikipedia.org/wiki/Base_36) encoding/decoding functions with the following or similar signatures:

function Base36Encode(Buffer: TBytes): string; overload;
function Base36Encode(const Buffer; BufSize: Integer): string; overload;
function Base36Decode(const S: string): TBytes;

My aim is to encode/decode GUIDs and other binary data in a manner that can be stored in a database CHAR (or VARCHAR) column with the least possible size but in such a way that value comparisons do not need to be case-sensitive. Thus far I've been using Base64 encoding for which I have found efficient routines, but base64 requires case-sensitive collation/comparisons and I would like to be able to avoid that.

Anybody knows where I could find such functions or care to share some? So far the only ones I've found encode/decode only a single 32-bit integer or a base10 string representation of a number and I would want to be able to encode/decode a binary buffer of arbitrary size.

Thank you in advance

-- Constantine

Reply by email