Conversion

Function

Description

uBase64Decode

Decodes a string from a Base64 representation

uBase64Encode

Encodes a string into a Base64 representation

uConvertDate

Converts a date string into the default or a custom date format

uFromHex

Converts a hexadecimal value into an integer value

uToHex

Converts an integer value into a hexadecimal digit

uHexDecode

Composes a string from hexadecimal values

uHexEncode

Encodes the characters of a string into hexadecimal notation

uToUnicode

Converts a string into its Unicode representation

uURIDecode

Decodes a string, replacing escape sequences with their original values

uURIEncode

Replaces certain characters in a URI with escape sequences




uBase64Decode

Description

Decodes a string from a Base64 representation

Syntax

string uBase64Decode(input)

Parameters

string input

The string to decode

Examples

Example 1

uBase64Decode("QSBzZWNyZXQ=") // returns "A secret"



uBase64Encode

Description

Encodes a string into a Base64 representation

Syntax

string uBase64Encode(input)

Parameters

string input

The string to encode.

Examples

Example 1

uBase64Encode("A secret") // returns "QSBzZWNyZXQ="



uConvertDate

Description

Converts a date string into the default or a custom date format.

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

Syntax

string uConvertDate(datestring, inputformat [, outputformat])

Parameters

string datestring

The date string to convert

string inputformat

The date/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

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"

Sybase recommends you to provide input data for all the fields required in the output data. Having fields in the output data for which no input data has been provided, can lead to unexpected results. For example, if you require hours, minutes, and seconds fields in the output data, your input data should be something similar to this:

uConvertDate("27 JUN 05", "D m Y", "y-m-D 00:00:00") // returns "2005-06-27 00:00:00" 

Usage

The function uConvertDate 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 (see list below). The outputformat parameter is optional; If omitted the date is converted using 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 is empty.

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

n

Month (June)

S

Seconds

s

Hundredth of seconds

t

Thousandth of seconds

A

AM/PM

d

Day of month (05)

E

Day of year (001 – 366)

G

Week of year (01 – 52)

F

Week of month (1 – 6)




uFromHex

Description

Converts a hexadecimal value into an integer value

Syntax

integer uFromHex(input)

Parameters

string input

The string to convert:

Examples

Example 1

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



uToHex

Description

Converts an integer value into a hexadecimal value

Syntax

string uToHex(input)

Parameters

integer input

The integer value to convert:

Examples

Example 1

uToHex(45) // returns "2D"



uHexDecode

Description

Composes a string from hexadecimal values

Syntax

string uHexDecode(input)

Parameters

string input

The hexadecimal string containing the hexadecimal values

Examples

Example 1

Convert a hexadecimal value to a string:

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



uHexEncode

Description

Encodes the characters of a string into hexadecimal notation

Syntax

string uHexEncode(input)

Parameters

string input

The string to encode

Examples

Example 1

Convert a string to hexadecimal values:

uHexEncode("170") // returns "313730"
uHexEncode(170)   // returns "313730"



uToUnicode

Description

Converts a string into its Unicode representation

Syntax

string uToUnicode(input)

Parameters

string input

The input string




uURIDecode

Description

Decodes a string, replacing escape sequences with their original values

Syntax

string uURIDecode(uri)

Parameters

string uri

The URI to decode

Examples

Example 1

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



uURIEncode

Description

Replaces certain characters in a URI with escape sequences

Syntax

string uURIEncode(uri)

Parameters

string uri

The URI to encode

Examples

Example 1

uURIEncode(“..www.myServer.com/filename with spaces.txt")// returns
“..www.myServer.com/filename%20with%20spaces.txt"