1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
class::Char
summary::ASCII character
related::Classes/String
categories:: Core
description::
An ASCII character represented as a signed 8-bit integer (-128 to 127).
Valid ASCII values are in the range 0-127.
Chars may be written as literals using the $ sign. For example: $a, $b, $c.
Some special characters can be expressed as literals using escape sequences (for example, code::$\n:: for newline).
See link::Reference/Literals#Characters:: for more information.
Chars may be created from link::Classes/Integer##Integers:: using the methods link::Classes/Integer#-asAscii:: and link::Classes/Integer#-asDigit::.
Note that, while Char does not support encodings aside from ASCII—such as
multi-byte encodings like UTF-8 and UTF-16, or the full Latin-1 (ISO 8859-1)
character set—Chars with negative values are perfectly legal, and may be strung
together in strings that use these encodings.
The SuperCollider IDE uses UTF-8 to decode and display strings.
See link::Classes/String:: for more information.
classmethods::
method::nl
Newline code::($\n)::.
method::ret
Carriage return code::($\r)::.
method::tab
Horizontal tab code::($\t)::.
method::ff
Form feed code::($\f)::.
method::vtab
Vertical tab code::($\v)::.
method::space
Single space code::($ )::.
method::comma
Comma code::($,)::.
method::bullet
Asterisk code::($*)::.
method::binaryOpCharacters
A string containing all characters allowed in a binary operator: code::"!@%&*-+=|<>?/"::.
instancemethods::
private:: archiveAsCompileString
subsection::conversion
method::ascii
returns:: the integer ASCII value of a Char.
method::digit
returns:: an integer value from 0 to 9 for chars $0 to $9, and values 10 to 35 for chars $a to $z
or $A to $Z.
method::toUpper
returns:: the upper case version of a char. Nonalphabetic chars return themselves.
method::toLower
returns:: a lower case version of a char. Nonalphabetic chars return themselves.
subsection:: Testing
method::isAlpha
returns:: whether the char is an alphabetic character.
method::isAlphaNum
returns:: whether the char is an alphabetic or numeric character.
method::isPrint
returns:: whether the char is printable.
method::isPunct
returns:: whether the char is a punctuation character.
method::isSpace
returns:: true if the char is white space: any of code::[$ , $\f, $\n, $\r, $\t, $\v]::.
method::isDecDigit
returns:: true if the char is a decimal digit $0 to $9.
method::isFileSafe
returns:: true if the char is safe for use in a filename.
Excludes the path separators / and :
discussion::
code::
for(0,255,{ arg i;
var a;
[i,a = i.asAscii,a.isAlphaNum,a.isPrint,a.isPunct,a.isControl].postln;
});
::
|