Scite Ascii 表格

lua-users home
wiki

显示 SciTE 编辑器当前的 8 位字符集。


-- 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


以列表形式显示,而不是网格形式。

--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


与上面相同,但显示十进制和十六进制(而不是仅显示十进制)。

列表显示在输出窗格中。

--------------------------------------------------------------------
-- 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

最近更改 · 偏好设置
编辑 · 历史记录
最后编辑于 2008 年 6 月 27 日上午 8:59 GMT (差异)