diff options
| author | unwox <me@unwox.com> | 2024-10-09 16:15:53 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-10-09 16:15:53 +0600 |
| commit | f91e38cc2da4758f42ca8ad14b4a9e0ba2b19c82 (patch) | |
| tree | da05f93c9f9fa544a9a9c7df19d70af29989a270 /main.go | |
| parent | 5be320e92ff9686df88c9943e72b9220e0d2cf50 (diff) | |
define utf lua module for utf-operations on strings
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -380,10 +380,35 @@ func main() { return 0 } + // define luna.utf module + utfModule := make(map[string]any) + utfModule["lower"] = func (l *Lua) int { + var str string + err := l.Scan(&str) + if err != nil { + // FIXME: handle. + return 0 + } + l.PushString(strings.ToLower(str)) + return 1 + } + utfModule["sub"] = func (l *Lua) int { + var str string + var start, length int + err := l.Scan(&str, &start, &length) + if err != nil { + // FIXME: handle. + return 0 + } + l.PushString(str[start-1:length]) + return 1 + } + module := make(map[string]any) module["router"] = routeModule module["http"] = httpModule module["db"] = dbModule + module["utf"] = utfModule wg := sync.WaitGroup{} wg.Add(*wrksNum) |
