uniwidth
Version, currently 0.1.24 versions
- 0.1.3latestOct 28, 2022
- 0.1.2not indexedOct 28, 2022
- 0.1.1not indexedOct 28, 2022
- 0.1.0not indexedOct 28, 2022
github.com/naqvis/uni_char_width
Provides methods to get fixed with of unicode character or string
Nothing has been indexed for 0.1.2 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
uniwidth:
github: naqvis/uni_char_width
version: ~> 0.1.2Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.2. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
Unicode Character & String Width
Shard Provides functionality to get fixed width of the unicode character or string.
For more information, refer to EAST ASIAN WIDTH Unicode Standard Annex #11 (Unicode version 13.0.0).
Installation
-
Add the dependency to your
shard.yml:dependencies: uniwidth: github: naqvis/uni_char_width -
Run
shards install
Usage
Code try to identify the locale and set east_asian property accordingly. You can enforce the code to enable CJK mode by setting EASTASIAN environment variable to "1". strict_emoji_neutral property is enabled by default, but this should be set to false for broken Fonts.
Module UnicodeCharWidth provided methods uses the default settings (stated above), if you need to tweak the settings, instantiate an instance of UnicodeCharWidth::Condition class with respective settings.
require "uniwidth"
# String/Char width
pp UnicodeCharWidth.width("つのだ☆HIRO") # => 12 on CJK locale
# Truncate
pp UnicodeCharWidth.truncate("つのだ☆HIRO",10,"...") # => "つのだ..."
# Padding
pp UnicodeCharWidth.pad_left("あxいうえお", 15) # => " あxいうえお"
pp UnicodeCharWidth.pad_right("あxいうえお", 15) # => "あxいうえお "
...
Refer to specs for more examples.
Development
To run all tests:
crystal spec
Contributing
- Fork it (https://github.com/naqvis/uni_char_width/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Ali Naqvi - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.2- Tagged
- Oct 28, 2022
- Commit
6ec0be420a6c- Indexed
- not yet
Dependents
Repository
github.com/naqvis/uni_char_width
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 23, 2026
- Synced
- Sep 22, 2026
- Versions
- 4