diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2015-05-04 23:10:29 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2015-05-04 23:11:06 +0200 |
commit | a79c845dba381f543d09526f77dcf2b4687b73a7 (patch) | |
tree | 8c42403a55c9c6736eb491331bfa7f650f807414 /lualibs-unicode.lua | |
parent | 9c35a373aa8e0edf14b686568fffab0e6969f447 (diff) | |
download | lualibs-a79c845dba381f543d09526f77dcf2b4687b73a7.tar.gz |
sync with Context as of 2015-05-04
Diffstat (limited to 'lualibs-unicode.lua')
-rw-r--r-- | lualibs-unicode.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lualibs-unicode.lua b/lualibs-unicode.lua index 02dd1a0..70b6032 100644 --- a/lualibs-unicode.lua +++ b/lualibs-unicode.lua @@ -418,9 +418,11 @@ if not utf.sub then end end - local pattern_zero = Cmt(p_utf8char,slide_zero)^0 - local pattern_one = Cmt(p_utf8char,slide_one )^0 - local pattern_two = Cmt(p_utf8char,slide_two )^0 + local pattern_zero = Cmt(p_utf8char,slide_zero)^0 + local pattern_one = Cmt(p_utf8char,slide_one )^0 + local pattern_two = Cmt(p_utf8char,slide_two )^0 + + local pattern_first = C(patterns.utf8character) function utf.sub(str,start,stop) if not start then @@ -463,7 +465,9 @@ if not utf.sub then end end end - if start > stop then + if start == 1 and stop == 1 then + return lpegmatch(pattern_first,str) or "" + elseif start > stop then return "" elseif start > 1 then b, e, n, first, last = 0, 0, 0, start - 1, stop |