isascii() — Test for 7-bit US-ASCII character

Standards

Standards / Extensions C or C++ Dependencies

XPG4
XPG4.2
Single UNIX Specification, Version 3

both POSIX(ON)

Format

_XOPEN_SOURCE:
#define _XOPEN_SOURCE
#include <ctype.h>

int isascii(int c);
_ALL_SOURCE:
#define _ALL_SOURCE
#include <ctype.h>

int isascii(int c);

General description

Special behavior for _XOPEN_SOURCE: The isascii() function tests whether c is a 7-bit US-ASCII character code. The isascii() function is defined on all integer values.

Special behavior for _ALL_SOURCE: The isascii() function tests whether the character with EBCDIC encoding c in the current locale is a member of the set of POSIX Portable Characters and POSIX Control Characters shown below.

Returned value

Special behavior for _XOPEN_SOURCE: isascii() returns nonzero if c is a 7-bit US-ASCII character code between 0 and hexadecimal 007F inclusive; otherwise it returns 0.

Special behavior for _ALL_SOURCE: isascii() returns nonzero if c is the EBCDIC encoding in the current locale for a character in the set of POSIX Portable Characters and Control Characters; otherwise it returns 0.

Following is a list of the symbolic names, IBM-1047 EBCDIC code page encoding, and ISO8859-1 ASCII encoding for the set of POSIX Portable Characters and POSIX Control Characters. Cases where EBCDIC character encoding varies across EBCDIC Country Extended Code Pages (CECPs) are noted.

Table 1. Characters for which isascii() returns nonzero
Character (Symbolic Name) IBM-1047 Encoding (Hex) ISO8859-1 Encoding (Hex)
<NUL> 00 00
<SOH> 01 01
<STX> 02 02
<ETX> 03 03
<EOT> 37 04
<ENQ> 2D 05
<ACK> 2E 06
<BEL> <alert> 2F 07
<BS> <backspace> 16 08
<HT> <tab> 05 09
<NL> <newline> 15 0A
<VT> <vertical-tab> 0B 0B
<FF> <form-feed> 0C 0C
<CR> <carriage-return> 0D 0D
<SO> 0E 0E
<SI> 0F 0F
<DLE> 10 10
<DC1> 11 11
<DC2> 12 12
<DC3> 13 13
<DC4> 3C 14
<NAK> 3D 15
<SYN> 32 16
<ETB> 26 17
<CAN> 18 18
<EM> 19 19
<SUB> 3F 1A
<ESC> 27 1B
<IFS/IS4> 1C 1C
<IGS/IS3> 1D 1D
<IRS/IS2> 1E 1E
<IUS/ITB/IS1> 1F 1F
<space> 40 20
<exclamation-mark> 5A (cecp variant) 21
<quotation-mark> 7F 22
<number-sign> 7B (cecp variant) 23
<dollar-sign> 5B (cecp variant) 24
<percent-sign> 6C 25
<ampersand> 50 26
<apostrophe> 7D 27
<left-parenthesis> 4D 28
<right-parenthesis> 5D 29
<asterisk> 5C 2A
<plus-sign> 4E 2B
<comma> 6B 2C
<hyphen> 60 2D
<period> 4B 2E
<slash> 61 2F
<zero> F0 30
<one> F1 31
<two> F2 32
<three> F3 33
<four> F4 34
<five> F5 35
<six> F6 36
<seven> F7 37
<eight> F8 38
<nine> F9 39
<colon> 7A 3A
<semicolon> 5E 3B
<less-than-sign> 4C 3C
<equals-sign> 7E 3D
<greater-than-sign> 6E 3E
<question-mark> 6F 3F
<commercial-at> 7C (cecp variant) 40
<A> C1 41
<B> C2 42
<C> C3 43
<D> C4 44
<E> C5 45
<F> C6 46
<G> C7 47
<H> C8 48
<I> C9 49
<J> D1 4A
<K> D2 4B
<L> D3 4C
<M> D4 4D
<N> D5 4E
<O> D6 4F
<P> D7 50
<Q> D8 51
<R> D9 52
<S> E2 53
<T> E3 54
<U> E4 55
<V> E5 56
<W> E6 57
<X> E7 58
<Y> E8 59
<Z> E9 5A
<left-square-bracket> AD (cecp variant) 5B
<backslash> E0 (cecp variant) 5C
<right-square-bracket> BD (cecp variant) 5D
<circumflex> 5F (cecp variant) 5E
<underscore> 6D 5F
<grave-accent> 79 (cecp variant) 60
<a> 81 61
<b> 82 62
<c> 83 63
<d> 84 64
<e> 85 65
<f> 86 66
<g> 87 67
<h> 88 68
<i> 89 69
<j> 91 6A
<k> 92 6B
<l> 93 6C
<m> 94 6D
<n> 95 6E
<o> 96 6F
<p> 97 70
<q> 98 71
<r> 99 72
<s> A2 73
<t> A3 74
<u> A4 75
<v> A5 76
<w> A6 77
<x> A7 78
<y> A8 79
<z> A9 7A
<left-brace> C0 (cecp variant) 7B
<vertical-line> 4F (cecp variant) 7C
<right-brace> D0 (cecp variant) 7D
<tilde> A1 (cecp variant) 7E
<DEL> 07 7F

Related information