Description
A port of ucwidth C library to Elixir, with Emoji (basis, variations and zwj-combined-sequences) supported.
Ucwidth alternatives and similar packages
Based on the "Third Party APIs" category.
Alternatively, view Ucwidth alternatives based on common mentions on social networks and blogs.
-
MongoosePush
MongoosePush is a simple Elixir RESTful service allowing to send push notification via FCM and/or APNS. -
sparkpost
SparkPost client library for Elixir https://developers.sparkpost.com -
elixtagram
:camera: Instagram API client for the Elixir language (elixir-lang) -
google_sheets
Elixir library for fetching Google Spreadsheet data in CSV format -
pay_pal
:money_with_wings: PayPal REST API client for the Elixir language (elixir-lang) -
amazon_product_advertising_client
An Amazon Product Advertising API client for Elixir -
cashier
Cashier is an Elixir library that aims to be an easy to use payment gateway, whilst offering the fault tolerance and scalability benefits of being built on top of Erlang/OTP -
elixir_ipfs_api
The Elixir library that is used to communicate with the IPFS REST endpoint.
Static code analysis for 29 languages.
Do you think we are missing an alternative of Ucwidth or a related project?
README
Ucwidth
A port of ucwidth C library to Elixir, with Emoji (basis, variations and zwj-combined-sequences) supported.
Motivation
When developing a terminal based Elixir application, I found lack of some library handling character width correctly. Turns out there's a need to port ucwidth to Elixir. So I made this library.
I'm not professional at Unicode, just read the specifications and some references. So please report any issues you meet, thanks in advance.
Usage
This library provides a function Ucwidth.width/2
for detecting the display width of a Unicode character.
For example:
iex> Ucwidth.width("行")
2
iex> Ucwidth.width("h")
1
iex> Ucwidth.width("\x0C")
0
iex> Ucwidth.width("Hello, <<👪>>, family lovers!")
29
Note: according to Unicode standard, not every character has fixed width. There are some characters with variable width, which is called ambiguous width characters
. Their width vary depends on the context. This library by default treats ambiguous charaters as narrow ones, and also provides a way to pass be context, e.g:
iex> Ucwidth.width("\u00a1")
1
iex> Ucwidth.width("\u00a1", :wide)
2
Installation
Add ucwidth
to your list of dependencies in mix.exs
:
def deps do
[
{:ucwidth, "~> 0.2"}
]
end
Performance
Attention to performance was paid during development. You can check the performance by running:
mix run bench/benchmark.exs
License
This library is open-sourced under an MIT license.
*Note that all licence references and agreements mentioned in the Ucwidth README section above
are relevant to that project's source code only.