You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 5, 2024. It is now read-only.
Neil Fraser edited this page Feb 13, 2018
·
2 revisions
Each language port of Diff Match Patch uses the same API. These are the language-specific notes regarding Lua.
A critical note with Lua is that (unlike most other languages) it does not have any awareness of Unicode. Thus:
string.len("中国") → 6
Strings in Lua are treated as a series of bytes, not a series of characters. This means that the functions in Diff Match Patch may return unexpected and non-printable results as it splits characters at the byte level.
A side effect of the lack of Unicode support is that the line-mode speedup in diff is not available.
Go to the lua directory and save the above program as hello.lua. Then execute lua hello.lua.
Tests
Unit tests can be performed from the lua/tests directory by executing lua diff_match_patch_test.lua. Over twenty test groups should run, with zero failures.
Speed test for diff can be performed from the lua/tests directory by executing lua speedtest.lua. It takes about 15 seconds.