Validate input Unicode codepoint

This commit is contained in:
Jipok 2021-12-12 02:49:15 +05:00
parent a3054bd45a
commit 3879d90b50
1 changed files with 6 additions and 1 deletions

View File

@ -123,7 +123,12 @@ local commands = {
["doc:type-unicode"] = function() ["doc:type-unicode"] = function()
core.command_view:enter("Unicode code point", function(text) core.command_view:enter("Unicode code point", function(text)
-- It is possible both HEX and DEC, tonumber will converts -- It is possible both HEX and DEC, tonumber will converts
doc():text_input(common.codepoint_to_utf8(tonumber(text))) local number = tonumber(text)
if number ~= nil then
doc():text_input(common.codepoint_to_utf8(number))
else
core.error("Wrong Unicode codepoint")
end
end) end)
core.command_view:set_text("0x") core.command_view:set_text("0x")
end, end,