- README

- Top Level Namespace
- Adler32
- ArgumentError
- Array
- Atomic
- Base64
  - Error
- Benchmark
  - BM
    - Job
    - Tms
  - IPS
    - Entry
    - Job
- BigFloat
- BigInt
- BigRational
- BitArray
- Bool
- Box
- Bytes
- Channel
  - Buffered
  - ClosedError
  - ReceiveAction
  - SelectAction
  - SendAction
  - Unbuffered
- Char
  - Reader
- Class
- Colorize
  - Object
  - ObjectExtensions
- Comparable
- Complex
- Concurrent
  - CanceledError
- CRC32
- Crypto
  - Bcrypt
    - Error
    - Password
  - Blowfish
  - Subtle
- CSV
  - Builder
    - Row
  - Error
  - Lexer
  - MalformedCSVError
  - Parser
  - Row
  - Token
    - Kind
- Debug
  - DWARF
    - Abbrev
      - Attribute
    - AT
    - FORM
    - Info
      - Value
    - LineNumbers
      - Register
      - Row
      - Sequence
    - LNE
    - LNS
    - Strings
    - TAG
  - ELF
    - Endianness
    - Error
    - Ident
    - Klass
    - Machine
    - OSABI
    - SectionHeader
      - Flags
      - Type
    - Type
- Deque
- Digest
  - Base
  - MD5
  - SHA1
- Dir
- DivisionByZero
- DL
- ECR
- Enum
- Enumerable
  - EmptyError
- ENV
- Errno
- Exception
- Fiber
- File
  - Stat
- FileUtils
- Flate
  - Error
  - Reader
  - Strategy
  - Writer
- Float
  - Primitive
- Float32
- Float64
- GC
  - Stats
- Gzip
  - Error
  - Header
  - Reader
  - Writer
- Hash
- HTML
- HTTP
  - Client
    - BodyType
    - Response
  - CompressHandler
  - ComputedContentTypeHeader
  - Cookie
  - Cookies
  - ErrorHandler
  - FormData
    - Builder
    - Error
    - FileMetadata
    - Parser
    - Part
  - Handler
    - Proc
  - Headers
  - LogHandler
  - Multipart
    - Builder
    - Error
    - Parser
  - Params
    - Builder
  - Request
  - Server
    - Context
    - RequestProcessor
    - Response
  - StaticFileHandler
    - DirectoryListing
  - WebSocket
  - WebSocketHandler
- Indexable
- IndexError
- INI
- Int
  - Primitive
  - Signed
  - Unsigned
- Int16
- Int32
- Int64
- Int8
- InvalidByteSequenceError
- IO
  - Buffered
  - ByteFormat
    - BigEndian
    - LittleEndian
    - NetworkEndian
    - SystemEndian
  - Delimited
  - EncodingOptions
  - EOFError
  - Error
  - FileDescriptor
  - Hexdump
  - Memory
  - MultiWriter
  - Seek
  - Sized
  - Timeout
- IPSocket
- Iterable
- Iterator
  - IteratorWrapper
  - Stop
- JSON
  - Any
  - Builder
    - ArrayState
    - DocumentEndState
    - DocumentStartState
    - ObjectState
    - StartState
    - State
  - Error
  - Lexer
  - ParseException
  - Parser
  - PullParser
  - Token
  - Type
- KeyError
- Levenshtein
  - Finder
- LLVM
  - ABI
    - AArch64
    - ArgKind
    - ArgType
    - ARM
    - FunctionType
    - X86
    - X86_64
      - RegClass
  - AtomicOrdering
  - AtomicRMWBinOp
  - Attribute
  - AttributeIndex
  - BasicBlock
  - BasicBlockCollection
  - Builder
  - CallConvention
  - CodeGenFileType
  - CodeGenOptLevel
  - CodeModel
  - Context
  - DIBuilder
  - DIFlags
  - DwarfTag
  - DwarfTypeEncoding
  - Function
  - FunctionCollection
  - FunctionPassManager
    - Runner
  - GenericValue
  - GlobalCollection
  - InstructionCollection
  - IntPredicate
  - JITCompiler
  - Linkage
  - MemoryBuffer
  - Module
  - ModuleFlag
  - ModulePassManager
  - ParameterCollection
  - PassManagerBuilder
  - PassRegistry
  - PhiTable
  - RealPredicate
  - RelocMode
  - Target
  - TargetData
  - TargetMachine
  - Type
    - Kind
  - Value
    - Kind
  - ValueMethods
  - VerifierFailureAction
- Logger
  - Formatter
  - Severity
- Markdown
  - HTMLRenderer
  - Parser
    - PrefixHeader
    - UnorderedList
  - Renderer
- Math
- Mutex
- NamedTuple
- Nil
- Number
  - Primitive
- OAuth
  - AccessToken
  - Consumer
  - Error
  - RequestToken
- OAuth2
  - AccessToken
    - Bearer
    - Mac
  - Client
  - Error
  - Session
- Object
- OpenSSL
  - Digest
    - Error
    - UnsupportedError
  - DigestBase
  - Error
  - HMAC
  - MD5
  - SHA1
  - SSL
    - Context
      - Client
      - Server
    - Error
    - ErrorType
    - Modes
    - Options
    - Socket
      - Client
      - Server
    - VerifyMode
    - X509VerifyFlags
- OptionParser
  - Exception
  - InvalidOption
  - MissingOption
- PartialComparable
- Pointer
  - Appender
- PrettyPrint
- Proc
- Process
  - Env
  - Status
  - Stdio
  - Tms
- Random
  - MT19937
- Range
- Readline
  - CompletionProc
  - KeyBindingProc
- Reference
- Reflect
- Regex
  - MatchData
  - Options
- SecureRandom
- Set
- Signal
- Slice
- Socket
  - Address
  - Addrinfo
  - Error
  - Family
  - IPAddress
  - Protocol
  - Server
  - Type
  - UNIXAddress
- Spec
  - Expectations
  - Methods
  - ObjectExtensions
- StaticArray
- String
  - Builder
  - RawConverter
- StringPool
- StringScanner
- Struct
- Symbol
- System
- TCPServer
- TCPSocket
- Tempfile
- Termios
  - AttributeSelection
  - BaudRate
  - ControlMode
  - InputMode
  - LineControl
  - LocalMode
  - OutputMode
- Time
  - DayOfWeek
  - EpochConverter
  - EpochMillisConverter
  - Format
    - Error
  - Kind
  - MonthSpan
  - Span
- Tuple
- TypeCastError
- UDPSocket
- UInt16
- UInt32
- UInt64
- UInt8
- Unicode
  - CaseOptions
- Union
- UNIXServer
- UNIXSocket
- URI
  - Error
- Value
- WeakRef
- XML
  - Attributes
  - AttributeType
  - Builder
  - Error
  - HTMLParserOptions
  - Namespace
  - Node
  - NodeSet
  - ParserOptions
  - Reader
  - SaveOptions
  - Type
  - XPathContext
- YAML
  - Any
  - Builder
  - Error
  - EventKind
  - ParseException
  - Parser
  - PullParser
  - Type
- Zip
  - CompressionMethod
  - Error
  - File
    - Entry
  - FileInfo
  - Reader
    - Entry
  - Writer
    - Entry
- Zlib
  - Error
  - Reader
  - Writer

# struct Char

- Char
- Value
- Object

## Overview

A `Char` represents a Unicode code point. It occupies 32 bits.

It is created by enclosing an UTF-8 character in single quotes.

    'a'
    'z'
    '0'
    '_'
    'あ'

You can use a backslash to denote some characters:

    '\'' # single quote
    '\\' # backslash
    '\e' # escape
    '\f' # form feed
    '\n' # newline
    '\r' # carriage return
    '\t' # tab
    '\v' # vertical tab

You can use a backslash followed by at most three digits to denote a code point written in octal:

You can use a backslash followed by an u and four hexadecimal characters to denote a unicode codepoint written:

    '\u0041' # == 'A'

Or you can use curly braces and specify up to four hexadecimal numbers:

    '\u{41}' # == 'A'

## Included Modules

- Comparable(Char)

## Defined in:

## Constant Summary

MAX = `1114111.unsafe_chr`

  The maximum character.

MAX_CODEPOINT = `1114111`

  The maximum valid codepoint for a character.

REPLACEMENT = `'�'`

  The replacement character, used on invalid utf-8 byte sequences

ZERO = `'\u{0}'`

  The character representing the end of a C string.

## Instance Method Summary

- #!=(other : Char) : Bool

  Returns `true` if `self`'s codepoint is not equal to other's codepoint.

- #+(str : String)

  Concatenates this char and string.

- #+(other : Int) : Char

  Returns a char that has this char's codepoint plus other.

- #-(other : Char)

  Returns the difference of the codepoint values of this char and other.

- #-(other : Int) : Char

  Returns a char that has this char's codepoint minus other.

- #<(other : Char) : Bool

  Returns `true` if `self`'s codepoint is less than other's codepoint.

- #<=(other : Char) : Bool

  Returns `true` if `self`'s codepoint is less than or equal to other's codepoint.

- #<=>(other : Char)

  Implements the comparison operator.

- #==(other : Char) : Bool

  Returns `true` if `self`'s codepoint is equal to other's codepoint.

- #===(byte : Int)

  Returns `true` if the codepoint is equal to byte ignoring the type.

- #>(other : Char) : Bool

  Returns `true` if `self`'s codepoint is greater than other's codepoint.

- #>=(other : Char) : Bool

  Returns `true` if `self`'s codepoint is greater than or equal to other's codepoint.

- #alphanumeric?

  Returns `true` if this char is a letter or a number according to unicode.

- #ascii?

  Returns `true` if this char is an ASCII character (codepoint is in (0..127))

- #ascii_alphanumeric?

  Returns `true` if this char is an ASCII letter or number ('0' to '9', 'a' to 'z', 'A' to 'Z').

- #ascii_control?

  Returns `true` if this char is an ASCII control character.

- #ascii_letter?

  Returns `true` if this char is an ASCII letter ('a' to 'z', 'A' to 'Z').

- #ascii_lowercase?

  Returns `true` if this char is a lowercase ASCII letter.

- #ascii_number?(base : Int = 10)

  Returns `true` if this char is an ASCII number in specified base.

- #ascii_uppercase?

  Returns `true` if this char is an ASCII uppercase letter.

- #ascii_whitespace?

  Returns `true` if this char is an ASCII whitespace.

- #bytes

  Returns this char bytes as encoded by UTF-8, as an `Array(UInt8)`.

- #bytesize

  Returns the number of UTF-8 bytes in this char.

- #clone
- #control?

  Returns `true` if this char is a control character according to unicode.

- #downcase(options = Unicode::CaseOptions::None)

  Returns the downcase equivalent of this char.

- #downcase(options = Unicode::CaseOptions::None, &block)

  Yields each char for the downcase equivalent of this char.

- #dump

  Returns this char as a string that contains a char literal as written in Crystal, with characters with a codepoint greater than `0x79` written as `\u{...}`.

- #dump(io)

  Appends this char as a string that contains a char literal to the given `IO`.

- #each_byte(&block) : Nil

  Yields each of the bytes of this char as encoded by UTF-8.

- #hash

  Returns this char's codepoint.

- #hex?

  Returns `true` if this char is an ASCII hex digit ('0' to '9', 'a' to 'z', 'A' to 'Z').

- #in_set?(*sets : String)

  Returns `true` if this char is matched by the given sets.

- #inspect

  Returns this char as a string that contains a char literal.

- #inspect(io)

  Appends this char as a string that contains a char literal to the given `IO`.

- #letter?

  Returns `true` if this char is a letter.

- #lowercase?

  Returns `true` if this char is a lowercase letter.

- #mark?

  Returns `true` if this is char is a mark character according to unicode.

- #number?

  Returns `true` if this char is a number according to unicode.

- #ord : Int32

  Returns the codepoint of this char.

- #pred

  Returns a Char that is one codepoint smaller than this char's codepoint.

- #succ

  Returns a Char that is one codepoint bigger than this char's codepoint.

- #to_f

  Returns the integer value of this char as a float if it's an ASCII char denoting a digit, raises otherwise.

- #to_f32

  See also: `#to_f`.

- #to_f32?

  See also: `#to_f?`.

- #to_f64

  Same as `#to_f`.

- #to_f64?

  Same as `#to_f?`.

- #to_f?

  Returns the integer value of this char as a float if it's an ASCII char denoting a digit, `nil` otherwise.

- #to_i(base : Int = 10) : Int32

  Returns the integer value of this char if it's an ASCII char denoting a digit in base, raises otherwise.

- #to_i16(base : Int = 10)

  See also: `#to_i`.

- #to_i16?(base : Int = 10)

  See also: `#to_i?`.

- #to_i32(base : Int = 10) : Int32

  Same as `#to_i`.

- #to_i32?(base : Int = 10) : Int32?

  Same as `#to_i?`.

- #to_i64(base : Int = 10)

  See also: `#to_i`.

- #to_i64?(base : Int = 10)

  See also: `#to_i?`.

- #to_i8(base : Int = 10)

  See also: `#to_i`.

- #to_i8?(base : Int = 10)

  See also: `#to_i?`.

- #to_i?(base : Int = 10) : Int32?

  Returns the integer value of this char if it's an ASCII char denoting a digit in base, `nil` otherwise.

- #to_s

  Returns this char as a string containing this char as a single character.

- #to_s(io : IO)

  Appends this char to the given `IO`.

- #to_u16(base : Int = 10)

  See also: `#to_i`.

- #to_u16?(base : Int = 10)

  See also: `#to_i?`.

- #to_u32(base : Int = 10)

  See also: `#to_i`.

- #to_u32?(base : Int = 10)

  See also: `#to_i?`.

- #to_u64(base : Int = 10)

  See also: `#to_i`.

- #to_u64?(base : Int = 10)

  See also: `#to_i?`.

- #to_u8(base : Int = 10)

  See also: `#to_i`.

- #to_u8?(base : Int = 10)

  See also: `#to_i?`.

- #upcase(options = Unicode::CaseOptions::None, &block)

  Yields each char for the upcase equivalent of this char.

- #upcase(options = Unicode::CaseOptions::None)

  Returns the upcase equivalent of this char.

- #uppercase?

  Returns `true` if this char is an uppercase letter.

- #whitespace?

  Returns `true` if this char is a whitespace according to unicode.

### Instance methods inherited from module `Comparable(Char)`

<(other : T) <, <=(other : T) <=, <=>(other : T) <=>, ==(other : T) ==, >(other : T) >, >=(other : T) >=

### Instance methods inherited from struct `Value`

==(other) ==, dup dup

### Instance methods inherited from class `Object`

!=(other) !=, !~(other) !~, ==(other) ==, ===(other : JSON::Any)
===(other : YAML::Any)
===(other) ===, =~(other) =~, class class, dup dup, hash hash, inspect(io : IO)
inspect inspect, itself itself, not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, tap(&block) tap, to_json(io : IO)
to_json to_json, to_pretty_json(indent : String = " ")
to_pretty_json(io : IO, indent : String = " ") to_pretty_json, to_s
to_s(io : IO) to_s, to_yaml(io : IO)
to_yaml to_yaml, try(&block) try

### Class methods inherited from class `Object`

from_json(string_or_io, root : String) : self
from_json(string_or_io) : self from_json, from_yaml(string_or_io) : self from_yaml

## Instance Method Detail

def !=(other : Char) : Bool #

Returns `true` if `self`'s codepoint is not equal to other's codepoint.

def +(str : String) #

Concatenates this char and string.

    'f' + "oo" # => "foo"

def +(other : Int) : Char #

Returns a char that has this char's codepoint plus other.

    'a' + 1 # => 'b'
    'a' + 2 # => 'c'

def -(other : Char) #

Returns the difference of the codepoint values of this char and other.

    'a' - 'a' # => 0
    'b' - 'a' # => 1
    'c' - 'a' # => 2

def -(other : Int) : Char #

Returns a char that has this char's codepoint minus other.

    'c' - 1 # => 'b'
    'c' - 2 # => 'a'

def <(other : Char) : Bool #

Returns `true` if `self`'s codepoint is less than other's codepoint.

def <=(other : Char) : Bool #

Returns `true` if `self`'s codepoint is less than or equal to other's codepoint.

def <=>(other : Char) #

Implements the comparison operator.

    'a' <=> 'c' # => -2

def ==(other : Char) : Bool #

Returns `true` if `self`'s codepoint is equal to other's codepoint.

def ===(byte : Int) #

Returns `true` if the codepoint is equal to byte ignoring the type.

    'c'.ord       # => 99
    'c' === 99_u8 # => true
    'c' === 99    # => true
    'z' === 99    # => false

def >(other : Char) : Bool #

Returns `true` if `self`'s codepoint is greater than other's codepoint.

def >=(other : Char) : Bool #

Returns `true` if `self`'s codepoint is greater than or equal to other's codepoint.

def alphanumeric? #

Returns `true` if this char is a letter or a number according to unicode.

    'c'.alphanumeric? # => true
    '8'.alphanumeric? # => true
    '.'.alphanumeric? # => false

def ascii? #

Returns `true` if this char is an ASCII character (codepoint is in (0..127))

def ascii_alphanumeric? #

Returns `true` if this char is an ASCII letter or number ('0' to '9', 'a' to 'z', 'A' to 'Z').

    'c'.ascii_alphanumeric? # => true
    '8'.ascii_alphanumeric? # => true
    '.'.ascii_alphanumeric? # => false

def ascii_control? #

Returns `true` if this char is an ASCII control character.

    ('\u0000'..'\u0019').each do |char|
      char.control? # => true
    end

    ('\u007F'..'\u009F').each do |char|
      char.control? # => true
    end

def ascii_letter? #

Returns `true` if this char is an ASCII letter ('a' to 'z', 'A' to 'Z').

    'c'.ascii_letter? # => true
    'á'.ascii_letter? # => false
    '8'.ascii_letter? # => false

def ascii_lowercase? #

Returns `true` if this char is a lowercase ASCII letter.

    'c'.ascii_lowercase? # => true
    'ç'.lowercase?       # => true
    'G'.ascii_lowercase? # => false
    '.'.ascii_lowercase? # => false

def ascii_number?(base : Int = 10) #

Returns `true` if this char is an ASCII number in specified base.

Base can be from 0 to 36 with digits from '0' to '9' and 'a' to 'z' or 'A' to 'Z'.

    '4'.ascii_number?     # => true
    'z'.ascii_number?     # => false
    'z'.ascii_number?(36) # => true

def ascii_uppercase? #

Returns `true` if this char is an ASCII uppercase letter.

    'H'.ascii_uppercase? # => true
    'Á'.ascii_uppercase? # => false
    'c'.ascii_uppercase? # => false
    '.'.ascii_uppercase? # => false

def ascii_whitespace? #

Returns `true` if this char is an ASCII whitespace.

    ' '.ascii_whitespace?  # => true
    '\t'.ascii_whitespace? # => true
    'b'.ascii_whitespace?  # => false

def bytes #

Returns this char bytes as encoded by UTF-8, as an `Array(UInt8)`.

    'a'.bytes # => [97]
    'あ'.bytes # => [227, 129, 130]

def bytesize #

Returns the number of UTF-8 bytes in this char.

    'a'.bytesize # => 1
    '好'.bytesize # => 3

def clone #
def control? #

Returns `true` if this char is a control character according to unicode.

def downcase(options = Unicode::CaseOptions::None) #

Returns the downcase equivalent of this char.

Note that this only works for characters whose downcase equivalent yields a single codepoint. There are a few characters, like 'İ', than when downcased result in multiple characters (in this case: 'I' and the dot mark).

For a more correct method see the method that receives a block.

    'Z'.downcase # => 'z'
    'x'.downcase # => 'x'
    '.'.downcase # => '.'

def downcase(options = Unicode::CaseOptions::None, &block) #

Yields each char for the downcase equivalent of this char.

This method takes into account the possibility that an downcase version of a char might result in multiple chars, like for 'İ', which results in 'i' and a dot mark.

def dump #

Returns this char as a string that contains a char literal as written in Crystal, with characters with a codepoint greater than `0x79` written as `\u{...}`.

    'a'.dump      # => "'a'"
    '\t'.dump     # => "'\\t'"
    'あ'.dump      # => "'\\u{3042}'"
    '\u0012'.dump # => "'\\u{12}'"

def dump(io) #

Appends this char as a string that contains a char literal to the given `IO`.

See also: `#dump`.

def each_byte(&block) : Nil #

Yields each of the bytes of this char as encoded by UTF-8.

    puts "'a'"
    'a'.each_byte do |byte|
      puts byte
    end
    puts

    puts "'あ'"
    'あ'.each_byte do |byte|
      puts byte
    end

Output:

    'a'
    97

    'あ'
    227
    129
    130

def hash #

Returns this char's codepoint.

def hex? #

Returns `true` if this char is an ASCII hex digit ('0' to '9', 'a' to 'z', 'A' to 'Z').

    '5'.hex? # => true
    'a'.hex? # => true
    'F'.hex? # => true
    'g'.hex? # => false

def in_set?(*sets : String) #

Returns `true` if this char is matched by the given sets.

Each parameter defines a set, the character is matched against the intersection of those, in other words it needs to match all sets.

If a set starts with a ^, it is negated. The sequence c1-c2 means all characters between and including c1 and c2 and is known as a range.

The backslash character \ can be used to escape ^ or - and is otherwise ignored unless it appears at the end of a range or the end of a a set.

    'l'.in_set? "lo"          # => true
    'l'.in_set? "lo", "o"     # => false
    'l'.in_set? "hello", "^l" # => false
    'l'.in_set? "j-m"         # => true

    '^'.in_set? "\\^aeiou" # => true
    '-'.in_set? "a\\-eo"   # => true

    '\\'.in_set? "\\"    # => true
    '\\'.in_set? "\\A"   # => false
    '\\'.in_set? "X-\\w" # => true

def inspect #

Returns this char as a string that contains a char literal.

    'a'.inspect      # => "'a'"
    '\t'.inspect     # => "'\\t'"
    'あ'.inspect      # => "'あ'"
    '\u0012'.inspect # => "'\\u{12}'"

def inspect(io) #

Appends this char as a string that contains a char literal to the given `IO`.

See also: `#inspect`.

def letter? #

Returns `true` if this char is a letter.

    'c'.letter? # => true
    'á'.letter? # => true
    '8'.letter? # => false

def lowercase? #

Returns `true` if this char is a lowercase letter.

    'c'.lowercase? # => true
    'ç'.lowercase? # => true
    'G'.lowercase? # => false
    '.'.lowercase? # => false

def mark? #

Returns `true` if this is char is a mark character according to unicode.

def number? #

Returns `true` if this char is a number according to unicode.

    '1'.number? # => true
    'a'.number? # => false

def ord : Int32 #

Returns the codepoint of this char.

The codepoint is the integer representation. The Universal Coded Character Set (UCS) standard, commonly known as Unicode, assigns names and meanings to numbers, these numbers are called codepoints.

For values below and including 127 this matches the ASCII codes and thus its byte representation.

    'a'.ord      # => 97
    '\0'.ord     # => 0
    '\u007f'.ord # => 127
    '☃'.ord      # => 9731

def pred #

Returns a Char that is one codepoint smaller than this char's codepoint.

    'b'.pred # => 'a'
    'ぃ'.pred # => 'あ'

def succ #

Returns a Char that is one codepoint bigger than this char's codepoint.

    'a'.succ # => 'b'
    'あ'.succ # => 'ぃ'

This method allows creating a `Range` of chars.

def to_f #

Returns the integer value of this char as a float if it's an ASCII char denoting a digit, raises otherwise.

    '1'.to_i # => 1.0
    '8'.to_i # => 8.0
    'c'.to_i # raises ArgumentError

def to_f32 #

See also: `#to_f`.

def to_f32? #

See also: `#to_f?`.

def to_f64 #

Same as `#to_f`.

def to_f64? #

Same as `#to_f?`.

def to_f? #

Returns the integer value of this char as a float if it's an ASCII char denoting a digit, `nil` otherwise.

    '1'.to_i # => 1.0
    '8'.to_i # => 8.0
    'c'.to_i # raises ArgumentError

def to_i(base : Int = 10) : Int32 #

Returns the integer value of this char if it's an ASCII char denoting a digit in base, raises otherwise.

    '1'.to_i     # => 1
    '8'.to_i     # => 8
    'c'.to_i     # raises ArgumentError
    '1'.to_i(16) # => 1
    'a'.to_i(16) # => 10
    'f'.to_i(16) # => 15
    'z'.to_i(16) # raises ArgumentError

def to_i16(base : Int = 10) #

See also: `#to_i`.

def to_i16?(base : Int = 10) #

See also: `#to_i?`.

def to_i32(base : Int = 10) : Int32 #

Same as `#to_i`.

def to_i32?(base : Int = 10) : Int32? #

Same as `#to_i?`.

def to_i64(base : Int = 10) #

See also: `#to_i`.

def to_i64?(base : Int = 10) #

See also: `#to_i?`.

def to_i8(base : Int = 10) #

See also: `#to_i`.

def to_i8?(base : Int = 10) #

See also: `#to_i?`.

def to_i?(base : Int = 10) : Int32? #

Returns the integer value of this char if it's an ASCII char denoting a digit in base, `nil` otherwise.

    '1'.to_i     # => 1
    '8'.to_i     # => 8
    'c'.to_i     # raises ArgumentError
    '1'.to_i(16) # => 1
    'a'.to_i(16) # => 10
    'f'.to_i(16) # => 15
    'z'.to_i(16) # raises ArgumentError

def to_s #

Returns this char as a string containing this char as a single character.

    'a'.to_s # => "a"
    'あ'.to_s # => "あ"

def to_s(io : IO) #

Appends this char to the given `IO`.

This appends this char's bytes as encoded by UTF-8 to the given `IO`.

def to_u16(base : Int = 10) #

See also: `#to_i`.

def to_u16?(base : Int = 10) #

See also: `#to_i?`.

def to_u32(base : Int = 10) #

See also: `#to_i`.

def to_u32?(base : Int = 10) #

See also: `#to_i?`.

def to_u64(base : Int = 10) #

See also: `#to_i`.

def to_u64?(base : Int = 10) #

See also: `#to_i?`.

def to_u8(base : Int = 10) #

See also: `#to_i`.

def to_u8?(base : Int = 10) #

See also: `#to_i?`.

def upcase(options = Unicode::CaseOptions::None, &block) #

Yields each char for the upcase equivalent of this char.

This method takes into account the possibility that an upcase version of a char might result in multiple chars, like for 'ﬄ', which results in 'F', 'F' and 'L'.

    'z'.upcase { |v| puts v } # prints 'Z'
    'ﬄ'.upcase { |v| puts v } # prints 'F', 'F', 'F'

def upcase(options = Unicode::CaseOptions::None) #

Returns the upcase equivalent of this char.

Note that this only works for characters whose upcase equivalent yields a single codepoint. There are a few characters, like 'ﬄ', than when upcased result in multiple characters (in this case: 'F', 'F', 'L').

For a more correct method see the method that receives a block.

    'z'.upcase # => 'Z'
    'X'.upcase # => 'X'
    '.'.upcase # => '.'

def uppercase? #

Returns `true` if this char is an uppercase letter.

    'H'.uppercase? # => true
    'Á'.uppercase? # => true
    'c'.uppercase? # => false
    '.'.uppercase? # => false

def whitespace? #

Returns `true` if this char is a whitespace according to unicode.

    ' '.whitespace?  # => true
    '\t'.whitespace? # => true
    'b'.whitespace?  # => false