All Projects → Stepets → Utf8.lua

Stepets / Utf8.lua

Licence: mit
pure-lua 5.3 regex library

Programming Languages

lua
6591 projects

Labels

Projects that are alternatives of or similar to Utf8.lua

Liko 12
LIKO-12 is an open source fantasy computer made using LÖVE.
Stars: ✭ 811 (+762.77%)
Mutual labels:  luajit
Luamqtt
luamqtt - Pure-lua MQTT v3.1.1 and v5.0 client
Stars: ✭ 58 (-38.3%)
Mutual labels:  luajit
Koreader Base
Base framework offering a Lua scriptable environment for creating document readers
Stars: ✭ 81 (-13.83%)
Mutual labels:  luajit
Nano Nginx
Nano container with nginx preconfigured as reverse proxy
Stars: ✭ 15 (-84.04%)
Mutual labels:  luajit
Vanilla
An OpenResty Lua MVC Web Framework
Stars: ✭ 1,018 (+982.98%)
Mutual labels:  luajit
Lgf
Game development framework for Lua
Stars: ✭ 68 (-27.66%)
Mutual labels:  luajit
Lua Nginx Redis
🌺 Redis、Lua、Nginx、OpenResty 笔记和资料
Stars: ✭ 757 (+705.32%)
Mutual labels:  luajit
Lua Resty Route
URL Routing Library for OpenResty Supporting Pluggable Matching Engines
Stars: ✭ 88 (-6.38%)
Mutual labels:  luajit
Koreader
An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices
Stars: ✭ 9,467 (+9971.28%)
Mutual labels:  luajit
Brat
Brat is a little language for people who don't like to be told what to do.
Stars: ✭ 78 (-17.02%)
Mutual labels:  luajit
Kong
🦍 The Cloud-Native API Gateway
Stars: ✭ 30,838 (+32706.38%)
Mutual labels:  luajit
Lua Resty Post
HTTP post utility for openresty
Stars: ✭ 30 (-68.09%)
Mutual labels:  luajit
Luajit Msgpack Pure
MessagePack for LuaJIT (using FFI, no bindings, V4 API)
Stars: ✭ 71 (-24.47%)
Mutual labels:  luajit
Luaty
Lua with more or less typing. You type less; we type check.
Stars: ✭ 9 (-90.43%)
Mutual labels:  luajit
Penlight
A set of pure Lua libraries focusing on input data handling (such as reading configuration files), functional programming (such as map, reduce, placeholder expressions,etc), and OS path management. Much of the functionality is inspired by the Python standard libraries.
Stars: ✭ 1,265 (+1245.74%)
Mutual labels:  luajit
Raptorjit
RaptorJIT: A dynamic language for system programming (LuaJIT fork)
Stars: ✭ 784 (+734.04%)
Mutual labels:  luajit
Pelagia
Automatic parallelization (lock-free multithreading thread) tool developed by Surparallel Open Source.Pelagia is embedded key value database that implements a small, fast, high-reliability on ANSI C.
Stars: ✭ 1,132 (+1104.26%)
Mutual labels:  luajit
Love
LÖVE is an awesome 2D game framework for Lua.
Stars: ✭ 1,305 (+1288.3%)
Mutual labels:  luajit
Android Luajit Launcher
Android NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI
Stars: ✭ 87 (-7.45%)
Mutual labels:  luajit
Pure lua sha
SHA1, SHA2 and SHA3 functions written in pure Lua and optimized for speed
Stars: ✭ 78 (-17.02%)
Mutual labels:  luajit

utf8.lua

pure-lua 5.3 regex library for Lua 5.3, Lua 5.1, LuaJIT

This library provides simple way to add UTF-8 support into your application.

Example:

local utf8 = require('.utf8'):init()
for k,v in pairs(utf8) do
  string[k] = v
end

local str = "пыщпыщ ололоо я водитель нло"
print(str:find("(.л.+)н"))
-- 8	26	ололоо я водитель

print(str:gsub("ло+", "보라"))
-- пыщпыщ о보라보라 я водитель н보라	3

print(str:match("^п[лопыщ ]*я"))
-- пыщпыщ ололоо я

Usage:

This library can be used as drop-in replacement for vanilla string library. It exports all vanilla functions under raw sub-object.

local utf8 = require('.utf8'):init()
local str = "пыщпыщ ололоо я водитель нло"
utf8.gsub(str, "ло+", "보라")
-- пыщпыщ о보라보라 я водитель н보라	3
utf8.raw.gsub(str, "ло+", "보라")
-- пыщпыщ о보라보라о я водитель н보라	3

It also provides all functions from Lua 5.3 UTF-8 module except utf8.len (s [, i [, j]]). If you need to validate your strings use utf8.validate(str, byte_pos) or iterate over with utf8.validator.

Installation:

Download repository to your project folder. (no rockspecs yet)

As of Lua 5.3 default utf8 module has precedence over user-provided. In this case you can specify full module path (.utf8).

Configuration:

Library is highly modular. You can provide your implementation for almost any function used. Library already has several back-ends:

Probably most interesting customizations are utf8.config.loadstring and utf8.config.cache if you want to precompile your regexes.

local utf8 = require('.utf8')
utf8.config = {
  cache = my_smart_cache,
}
utf8:init()

Customization is done before initialization. If you want, you can change configuration after init, it might work for everything but modules. All of them should be reloaded.

Documentation:

Issue reporting:

Please provide example script that causes error together with environment description and debug output. Debug output can be obtained like:

local utf8 = require('.utf8')
utf8.config = {
  debug = utf8:require("util").debug
}
utf8:init()
-- your code

Default logger used is io.write and can be changed by specifying logger = my_logger in configuration

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].