Name

decode_to_intvec — decode an alphabet-encoded string into a vector of integers

Synopsis

any decode_to_intvec( in in_string varchar,
  in alphabet varchar,
  in out_width_in_bits integer);
 

Description

decode_to_intvec interprets in_string as a sequence of symbols drawn from alphabet, packs the corresponding bit fields, and returns them as a Virtuoso integer vector whose element width is out_width_in_bits.

alphabet must contain exactly 2, 4, 8, 16, 32, 64, 128, or 256 distinct characters; each input character then contributes log2(length(alphabet)) bits. A typical alphabet for uuencode-style and traditional crypt salts is abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./ (64 characters, six bits each).

out_width_in_bits must be between 1 and 32 inclusive. With width 1 the result is a bit vector; with 8, a byte vector; with 16 or 32, word or longword elements. Mainly a helper for legacy data import and decoding of crypt/uuencode-style strings.

Parameters

in_string

The encoded input string. Characters not present in alphabet contribute a zero symbol. A SQL NULL yields NULL.

alphabet

A string of length 2, 4, 8, 16, 32, 64, 128, or 256 giving the symbol alphabet. Other lengths raise SQLSTATE 21S01 / GN001.

out_width_in_bits

Element width in bits for the result vector (1–32). Values outside that range raise SQLSTATE 21S01 / GN002.

Return Types

An integer vector (any / array of long), or NULL when in_string is NULL.

Examples

Example 24.245. Decode a 64-character alphabet string into 8-bit values

SQL> select decode_to_intvec (
  'ab',
  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./',
  8);
      


© 1992 - OpenLink Software. All rights reserved.

Making Technology Work for You®