.cr
Crystal
(text/x-crystal)
struct Char
  def self.new(codepoint : Int)
    codepoint.unsafe_chr
  end

  def ord
    # Intrinsics.convert self, Int32
    func = self
    pointerof(func).unsafe_as(Int32)
  end

  def ==(other : Char)
    ord == other.ord
  end

  def to_s(io)
    io.putc ord.to_u8
  end

  def to_s
    String.build(1) do |str|
      str << self
    end
  end

  def to_u8
    ord.to_u8
  end
end