Scite Hexify |
|
此脚本将选定文本转换为 C 语言中使用的转义十六进制形式。使用撤销 (Undo) 可以移除转换后的形式。
例如 "abc" -> "\x61\x62\x63", Latin-1 编码的 "���T�" -> "\x8a\xe7\xef\x54\xca", UTF-8 编码的 "���T�" -> "\xc5\xa0\xc3\xa7\xc3\xaf\x54\xc3\x8a"。
-- Convert a string to a string of hex escapes function Hexify(s) local hexits = "" for i = 1, string.len(s) do hexits = hexits .. string.format("\\x%2x", string.byte(s, i)) end return hexits end -- Convert the selection to hex escaped form -- command.name.1.*=Hexify Selection -- command.mode.1.*=subsystem:lua,savebefore:no -- command.1.*=HexifySelection function HexifySelection() editor:ReplaceSel(Hexify(editor:GetSelText())) end