Skip to content
/ luabidi Public

Lua implementation of the Unicode Bidirectional Algorithm

License

Notifications You must be signed in to change notification settings

ufyTeX/luabidi

Repository files navigation

luabidi

Lua implementation of the Unicode Bidirectional Algorithm, as specified in UAX #9.

Installing

luarocks install luabidi

Documentation

Quickstart

local bidi = require('bidi')
local serpent  = require('serpent') -- luarocks install serpent

local text = {0x06CC, 0x06C1} -- "یہ" U+06CC U+06C1

local reordered_text = bidi.get_visual_reordering(text)

-- hex representation
for i,v in ipairs(reordered_text) do
  reordered_text[i] = string.format("U+%04X", v)
end

for i,v in ipairs(text) do
  text[i] = string.format("U+%04X", v)
end

print("Original codepoints (in logical order): " .. serpent.line(text,{comment = false}))
print("Visual reordering: " .. serpent.line(reordered_text,{comment = false})) -- should be { "U+06C1", "U+06CC"}

More sample code in the examples folder.

Development

Building

luarocks make

Testing and Linting

In order to make changes to the code and run the tests, the following dependencies need to be installed:

  • Bustedluarocks install busted
  • luacheckluarocks install luacheck

Run the test suite:

make spec

Lint the codebase:

make lint

Contact

Open a Github issue, or email me at deepak.jois@gmail.com.

About

Lua implementation of the Unicode Bidirectional Algorithm

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages