ascii Method

Class: byteString

Description

This method returns the ASCII code of the byte at the specified position of the byte string, or -1 if the specified position is greater than ByteString.length() or less than 1.

 

 

image\msgs.gif

The value is always in the range -1 to 255 (inclusive), regardless of the value of Runtime.charsetName.

Syntax

ByteString.ascii(Number position)

Parameters

position

The position of the character. The default value is 1.

Returns

An integer value in the range -1 to 255

When Became Available

Profile V7.0

Example

// example assumes Runtime.charsetName = "UTF-8"

// The German character ä is represented by the byte sequence 195,164

type String     CHST = "Bär"

type ByteString BTST = CHST.toByteString()

type Number NUM1 = BTST.ascii(2) // NUM1 = 195

type Number NUM2 = BTST.ascii(3) // NUM2 - 164

type Number NUM3 = BTST.ascii(4) // NUM3 = 114

type Number NUM4 = BTST.ascii(5) // NUM4 = -1 (beyond BTST.length())