Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drmargarido/printable_chars
Display ascii printable chars in string
https://github.com/drmargarido/printable_chars
Last synced: 3 months ago
JSON representation
Display ascii printable chars in string
- Host: GitHub
- URL: https://github.com/drmargarido/printable_chars
- Owner: drmargarido
- License: mit
- Created: 2018-11-29T22:08:26.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-12T19:37:53.000Z (over 5 years ago)
- Last Synced: 2024-06-09T21:42:48.670Z (5 months ago)
- Language: Lua
- Size: 7.81 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Printable Chars
Simple lib for getting the printable ascii characters of a lua string
## Example Usage
```lua
local printable_chars = require "printable_chars".printable_chars-- Print random characters from urandom
local urandom = io:open("/dev/urandom", "r")
print(printable_chars(urandom:read(32))) -- U&0j]s7\]r9\ (Example)
urandom:close()-- Validate fields
local raw_password = "çç~asdasdasd \n\n\r\tasdáá"
if raw_password ~= printable_chars(raw_password) then -- True
print("Do not use invalid ascii characters in the password")
end
```Check [spec](spec/app_spec.lua) file for more examples
## Available methods
* printable_chars - Returns string with just the ascii printable characters
* is_char_printable - Checks if a char is printable
* set_spaces_allowed - Sets the lib to accept special space chars as printable chars
* blacklist_chars - Blacklists a list of specific chars so the next printable_chars calls will ignore them## Testing
To run the unit tests we need the busted lib.
```sh
luarocks install busted
```After that just run the following command.
```sh
busted spec
```## Instalation
```sh
luarocks install printable_chars
```