ascii

package
v0.0.0-...-7272a43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package ascii provides static methods pertaining to ASCII characters (those in the range of values 0x00 through 0x7F), and to strings containing such characters.

Index

Constants

View Source
const ACK byte = 6

ACK (Acknowledge): A communication control character transmitted by a receiver as an affirmative response to a sender.

View Source
const BEL byte = 7

BEL (Bell - '\a'): A character for use when there is a need to call for human attention. It may control alarm or attention devices.

View Source
const BS byte = 8

BS (Backspace - '\b'): A format effector which controls the movement of the printing position one printing space backward on the same printing line. (Applicable also to display devices.)

View Source
const CAN byte = 24

CAN (Cancel): A control character used to indicate that the data with which it is sent is in error or is to be disregarded.

View Source
const CR byte = 13

CR (Carriage Return - '\r'): A format effector which controls the movement of the printing position to the first printing position on the same printing line. (Applicable also to display devices.)

View Source
const DC1 byte = 17 // aka XON

DC1 (Device Control 1): Characters for the control of ancillary devices associated with data processing or telecommunication systems, more especially switching devices "on" or "off." (If a single "stop" control is required to interrupt or turn off ancillary devices, DC4 is the preferred assignment.)

View Source
const DC2 byte = 18

DC2 (Device Control 2): Characters for the control of ancillary devices associated with data processing or telecommunication systems, more especially switching devices "on" or "off." (If a single "stop" control is required to interrupt or turn off ancillary devices, DC4 is the preferred assignment.)

View Source
const DC3 byte = 19 // aka XOFF

DC3 (Device Control 3): Characters for the control of ancillary devices associated with data processing or telecommunication systems, more especially switching devices "on" or "off." (If a single "stop" control is required to interrupt or turn off ancillary devices, DC4 is the preferred assignment.)

View Source
const DC4 byte = 20

DC4 (Device Control 4): Characters for the control of ancillary devices associated with data processing or telecommunication systems, more especially switching devices "on" or "off." (If a single "stop" control is required to interrupt or turn off ancillary devices, DC4 is the preferred assignment.)

View Source
const DEL byte = 127

DEL (Delete): This character is used primarily to "erase" or "obliterate" erroneous or unwanted characters in perforated tape.

View Source
const DLE byte = 16

DLE (Data Link Escape): A communication control character which will change the meaning of a limited number of contiguously following characters. It is used exclusively to provide supplementary controls in data communication networks.

View Source
const EM byte = 25

EM (End of Medium): A control character associated with the sent data which may be used to identify the physical end of the medium, or the end of the used, or wanted, portion of information recorded on a medium. (The position of this character does not necessarily correspond to the physical end of the medium.)

View Source
const ENQ byte = 5

ENQ (Enquiry): A communication control character used in data communication systems as a request for a response from a remote station. It may be used as a "Who Are You" (WRU) to obtain identification, or may be used to obtain station status, or both.

View Source
const EOT byte = 4

EOT (End of Transmission): A communication control character used to indicate the conclusion of a transmission, which may have contained one or more texts and any associated headings.

View Source
const ESC byte = 27

ESC (Escape): A control character intended to provide code extension (supplementary characters) in general information interchange. The Escape character itself is a prefix affecting the interpretation of a limited number of contiguously following characters.

View Source
const ETB byte = 23

ETB (End of Transmission Block): A communication control character used to indicate the end of a block of data for communication purposes. ETB is used for blocking data where the block structure is not necessarily related to the processing format.

View Source
const ETX byte = 3

ETX (End of Text): A communication control character used to terminate a sequence of characters started with STX and transmitted as an entity.

View Source
const FF byte = 12

FF (Form Feed - '\f'): A format effector which controls the movement of the printing position to the first pre-determined printing line on the next form or page. (Applicable also to display devices.)

View Source
const FS byte = 28

FS (File Separator): These four information separators may be used within data in optional fashion, except that their hierarchical relationship shall be: FS is the most inclusive, then GS, then RS, and US is least inclusive. (The content and length of a File, Group, Record, or Unit are not specified.)

View Source
const GS byte = 29

GS (Group Separator): These four information separators may be used within data in optional fashion, except that their hierarchical relationship shall be: FS is the most inclusive, then GS, then RS, and US is least inclusive. (The content and length of a File, Group, Record, or Unit are not specified.)

View Source
const HT byte = 9

HT (Horizontal Tabulation - '\t'): A format effector which controls the movement of the printing position to the next in a series of predetermined positions along the printing line. (Applicable also to display devices and the skip function on punched cards.)

View Source
const LF byte = 10

LF (Line Feed - '\n'): A format effector which controls the movement of the printing position to the next printing line. (Applicable also to display devices.) Where appropriate, this character may have the meaning "New Line" (NL), a format effector which controls the movement of the printing point to the first printing position on the next printing line. Use of this convention requires agreement between sender and recipient of data.

View Source
const MAX byte = 127

MAX is the maximum value of an ASCII character.

View Source
const MIN byte = 0

MIN is the minimum value of an ASCII character.

View Source
const NAK byte = 21

NAK (Negative Acknowledge): A communication control character transmitted by a receiver as a negative response to the sender.

View Source
const NL byte = 10

NL (New Line): Alternate name for LF. (LF is preferred.)

View Source
const NUL byte = 0

NUL ('\0'): The all-zeros character which may serve to accomplish time fill and media fill. Normally used as a C string terminator. Although RFC 20 names this as "Null", note that it is distinct from the C/C++ "NULL" pointer.

View Source
const RS byte = 30

RS (Record Separator): These four information separators may be used within data in optional fashion, except that their hierarchical relationship shall be: FS is the most inclusive, then GS, then RS, and US is least inclusive. (The content and length of a File, Group, Record, or Unit are not specified.)

View Source
const SI byte = 15

SI (Shift In): A control character indicating that the code combinations which follow shall be interpreted according to the standard code table.

View Source
const SO byte = 14

SO (Shift Out): A control character indicating that the code combinations which follow shall be interpreted as outside of the character set of the standard code table until a Shift In character is reached.

View Source
const SOH byte = 1

SOH (Start of Heading): A communication control character used at the beginning of a sequence of characters which constitute a machine-sensible address or routing information. Such a sequence is referred to as the "heading." An STX character has the effect of terminating a heading.

View Source
const SP byte = 32

SP (Space): A normally non-printing graphic character used to separate words. It is also a format effector which controls the movement of the printing position, one printing position forward. (Applicable also to display devices.)

View Source
const SPACE byte = 32

SPACE is an alternate name for SP.

View Source
const STX byte = 2

STX (Start of Text): A communication control character which precedes a sequence of characters that is to be treated as an entity and entirely transmitted through to the ultimate destination. Such a sequence is referred to as "text." STX may be used to terminate a sequence of characters started by SOH.

View Source
const SUB byte = 26

SUB (Substitute): A character that may be substituted for a character which is determined to be invalid or in error.

View Source
const SYN byte = 22

SYN (Synchronous Idle): A communication control character used by a synchronous transmission system in the absence of any other character to provide a signal from which synchronism may be achieved or retained.

View Source
const US byte = 31

US (Unit Separator): These four information separators may be used within data in optional fashion, except that their hierarchical relationship shall be: FS is the most inclusive, then GS, then RS, and US is least inclusive. (The content and length of a File, Group, Record, or Unit are not specified.)

View Source
const VT byte = 11

VT (Vertical Tabulation - '\v'): A format effector which controls the movement of the printing position to the next in a series of predetermined printing lines. (Applicable also to display devices.

View Source
const XOFF byte = 19 // aka DC3

XOFF (Transmission off): See XON for explanation.

View Source
const XON byte = 17 // aka DC1

XON (Transmission On): Although originally defined as DC1, this ASCII control character is now better known as the XON code used for software flow control in serial communications. The main use is restarting the transmission after the communication has been stopped by the XOFF control code.

Variables

This section is empty.

Functions

func IsLowerCase

func IsLowerCase(c byte) bool

IsLowerCase indicates whether b is one of the twenty-six lowercase ASCII alphabetic characters between 'a' and 'z' inclusive. All others (including non-ASCII characters) return false.

func IsUpperCase

func IsUpperCase(c byte) bool

IsUpperCase indicates whether b is one of the twenty-six uppercase ASCII alphabetic characters between 'A' and 'Z' inclusive. All others (including non-ASCII characters) return false.

func ToLowerCase

func ToLowerCase(c byte) byte

ToLowerCase returns the lowercase equivalent if the argument is an uppercase ASCII character. Otherwise, returns the argument.

func ToUpperCase

func ToUpperCase(c byte) byte

ToUpperCase returns the uppercase equivalent if the argument is a lowercase ASCII character. Otherwise, returns the argument.

func Truncate

func Truncate(str string, maxLen int, truncInd string) (string, error)

Truncate truncates the given string to the given maximum length. If the length of the string is greater than maxLen, the returned string will be exactly maxLen chars in length and will end with the given truncInd. Otherwise, the string will be returned with no changes to the content.

Examples:

ascii.Truncate("foobar", 7, "...") // returns "foobar"
ascii.Truncate("foobar", 5, "...") // returns "fo..."

Note: This function may work with certain non-ASCII text but is not safe for use with arbitrary Unicode text. It is mostly intended for use with text that is known to be safe for use with it (such as all-ASCII text) and for simple debugging text. When using this method, consider the following:

• it may split surrogate pairs

• it may split characters and combining characters

• it does not consider word boundaries

• if truncating for display to users, there are other considerations that must be taken into account

• the appropriate truncation indicator may be locale-dependent

• it is safe to use non-ASCII characters in the truncation indicator

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL