summaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/util.lua b/util.lua
index da9702e..99f8fe8 100644
--- a/util.lua
+++ b/util.lua
@@ -22,6 +22,14 @@ function util.strip(str)
return (str:gsub('^%s*(.-)%s*$', '%1'))
end
+function util.strip_ne(str)
+ if str == nil then
+ return nil
+ end
+ local str = util.strip(tostring(str))
+ return str ~= '' and str or nil
+end
+
-- skips over utf8 continuation bytes (10xxxxxx)
-- valid positions range from 1 to #str + 1 (*after* the last byte)
function util.utf8_seek(str, pos, n)