Scite Ascii Table

lua-users home
wiki

Displays the current 8-bit character set of the SciTE editor.


-- ASCII Table for SciTE; khman 20050812; public domain
function ASCIITable()
  local Ctrl = false -- set to true if ASCII<32 appear as valid chars
  scite.Open("")
  local hl = "    +----------------+\n"
  editor:AddText("ASCII Table:\n"..hl.."Hex |0123456789ABCDEF|\n"..hl)
  local start = Ctrl and 0 or 32
  for x = start, 240, 16 do
    editor:AddText(string.format(" %02X |", x))
    for y = x, x+15 do editor:AddText(string.char(y)) end
    editor:AddText("|\n")
  end
  editor:AddText(hl)
  if not Ctrl then
    editor:AddText(
      "\nControl Characters:\n"..
      " 00: NUL SOH STX ETX\n 04: EOT ENQ ACK BEL\n"..
      " 08: BS  HT  LF  VT\n 0C: FF  CR  SO  SI\n"..
      " 10: DLE DC1 DC2 DC3\n 14: DC4 NAK SYN ETB\n"..
      " 18: CAN EM  SUB ESC\n 1C: FS  GS  RS  US\n"
    )
  end
end


Display in one list, rather than a grid:

--Ben Fisher, 2006, Public domain
function ascii_table()
	local padnum = function (nIn)
		if nIn < 10 then return "00"..nIn
		elseif nIn < 100 then return "0"..nIn
		else return nIn
		end
	end
	local overrides = { [0]="(Null)", [9]="(Tab)",[10]="(\\n Newline)", [13]="(\\r Return)", [32]="(Space)"}
	local c
	for n=0,126 do
		if overrides[n] then c = overrides[n] else c = string.char(n) end
		print (padnum(n).."  "..c)
	end
end


Same as above but displays decimal & hex (rather than just decimal)

List is displayed in output pane

--------------------------------------------------------------------
-- Ascii Table
-- Original code by Ben Fisher
-- Improved by Paul Heasley (www.phdesign.com.au)
--------------------------------------------------------------------

function AsciiTable()
	local overrides = { [0]="(Null)", [9]="(Tab)",[10]="(\\n Newline)", [13]="(\\r Return)", [32]="(Space)"}
	local c
	for n=0,126 do
		if overrides[n] then c = overrides[n] else c = string.char(n) end
		print (string.format("%03d 0x%02x %s", n, n, c))
	end
end

RecentChanges · preferences
edit · history
Last edited June 27, 2008 8:59 am GMT (diff)