Conversion functions




uBase64Decode

Description

Decodes a string from a Base64 representation.

Syntax

string uBase64Decode(input)

Parameters

string input

The string to decode.

Examples

Example 1

To encode a string from Base64:

uBase64Dcode("QQAgAHMAZQA=") ;; returns "A secret="



uBase64Encode

Description

Decodes a string into a Base64 representation.

Syntax

string uBase64Encode(input)

Parameters

string input

The string to decode.

Examples

Example 1

To encode a string into a Base64 representation:

uBase64DEncode("A secret") ;; returns "QQAgAHMAZQA="



uConvertDate

Description

Converts a date string into a different format using a source and a destination format string: The first parameter is the date string to be converted; the second parameter is a format string, specifying the date format of the input date string (see the following table). The outputformat parameter is optional, and if it is omitted, the date is converted in the format y-M-D H:N:S.

The function handles dates from 1582 to present day. If the date cannot be converted, the result string will be empty.

Table 7-1: Date Conversion identifiers

Identifier

Description

Y

Year 2-digits (06)

y

Year 4-digits (2006)

C

Century (20)

M

Month (03)

m

Month (JUN)

D

Day (12)

H

Hour (00..23)

h

Hour (01..12)

N

Minutes

S

Seconds

s

Hundreths of seconds

t

Thousandth of seconds

A

AM/PM

d

Day of week (5)

D

Day of week (Friday)

E

Day of year (001..366)

G

Week of year (01..52)

F

Week of month (1..6)

Syntax

string uConvertDate(datestring, inputformat [, outputformat])

Parameters

string datestring

The string to convert.

string inputformat

The date and time format of the input string.

string outputformat

(optional) The desired output format. If omitted, the default format is y-M-D H:N:S.

Examples

Example 1

To convert date strings into a different formats:

uConvertDate("2005-06-27 00:00:00","y-M-D H:N:S","D mY") // returns "27 JUN 05" 
uConvertDate("27 JUN 05", "D m Y") // returns "2005-06-27 00:00:00"



uFromHex

Description

Converts a string of hexadecimal numbers into an integer.

Syntax

integer uFromHex (input)

Parameters

string input

The string to convert.

Examples

Example 1

Convert a hexadecimal string

uFromHex("A3F") // returns 2623
uFromHex("B") // returns 11



uToHex

Description

Converts an integer value into a hexadecimal string.

Syntax

string uToHex (input)

Parameters

integer input

The integer to convert.

Examples

Example 1

To convert an integer:

uToHex(45) // returns “2D”




uHexDecode

Description

Composes a string from hexadecimal values.

Syntax

string uHexDecode(input)

Examples

Example 1

To compose a string from hex values:

uHexDecode("313730") // returns "170"
uHexDecode(313730)   // returns "170"



uHexEncode

Description

Encodes every character of a string into its hexadecimal notation

Syntax

string uHexEncode(input)

Parameters

string input

The string to encode.

Examples

Example 1

To convert a string to hex values:

uHexEncode("170") // returns "3313730"
uHexEncode(170) // returns "3313730"



uToUnicode

Description

Converts a string into Unicode.

Syntax

string uToUnicode (input , [codepage]

Parameters

string input

The input string.




uURIDecode

Description

Returns a decoded string replacing the escape sequences with their original values.

Syntax

string uURIDecode(uri)

Parameters

string uri

The URI to decode.

Examples

Example 1

To decode a URI:

uURIDecode("www.sybase.com/filename%20with%20spaces.txt") // returns "www.sybase.com/filename with spaces.txt"



uURIEncode

Description

Returns a new version of a complete URI, replacing each instance of certain characters with escape sequences representing the UTF-8 encoding of the characters.

Syntax

string uURIEncode(uri)

Parameters

string uri

The URI to encode.

Examples

Example 1

To encode a URI:

uURIEncode("www.sybase.com/filename with spaces.txt") // returns "www.sybase.com/filename%20with%20spaces.txt”