kip
ex_cldr Core Team
Following on from my CLDR lbraries I started work on Unicode transforms. But like everything related to CLDR there is a lot of yak-shaving and rabbit-hole travelling required.
The net result is a bunch of new libraries designed to make it easier to work with Unicode blocks, scripts, categories, properties and sets. These are:
- ex_unicode that introspects a string or code point and tells you a lot more than you probably want to know. Buts is a good building block for other libraries.
- unicode_set supports the Unicode Set syntax and provides the macro
Unicode.Set.match?/2that can be used to build clever guards to match on Unicode blocks, scripts, categories and properties. - unicode_guards uses
ex_unicodeandunicode_setto provide a set of prepackaged unicode-friendly guards. Such asis_upper/1,is_lower/1,is_currency_symbol/1,is_whitespace/1andis_digit/1. - unicode_transform is a work in progress to implement the unicode transform specification and to generate transformation modules.
- unicode_string will be the last part of this series that will provide functions to split and replace strings based upon unicode sets. Work hasn’t yet started but its going to be a fun project.
Unicode sets in particular allow some cool expressions. For example:
require Unicode.Set
# Is a given code point a digit? This is the
# digit `1` in the Thai script
iex> Unicode.Set.match?(?๓, "[[:digit:]]")
true
# What if we want to match on digits, but not Thai digits?
# Use set difference!
iex> Unicode.Set.match?(?๓, "[[:digit:]-[:thai:]]")
false
Since Unicode.Set.match?/2 is a macro, all the work of parsing, extracting code points, doing set operations and generating the guard code is done at compile time. The resulting code runs about 3 to 8 times faster than a regex case. (although of course regex has a much larger problem domain).
Trending in Announcing
WebAuthnLiveComponent WebAuthnComponents
See this post about renaming the package.
Passwordless authentication for Phoenix LiveView app...
New
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I released Doggo, a collection of unstyled Phoenix components.
https://github.com/woylie/doggo
Features
Unstyled Phoenix components....
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hi everyone,
I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
I’ll shortly be launching Text, a nascent text analysis library.
Current functionality
In this early version (not ready for prime time) ...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
tmbb
You should think of renaming your modules so that
Unicode.SetbecomesUnicodeSetinstead, or at leastUnicode.UnicodeSetif you want to make it clear that everything is under theUnicodenamespace. The original name (Unicode.Set) doesn’t play well withaliasing.kip
Added two helpful functions in version 0.2.0 that:
String.split/3andString.replace/3:Generating compiled patterns for String matching
String.split/3andString.replace/3allow for patterns and compiled patterns to be used with compiled patterns being the more performant approach. Unicode Set supports the generation of patterns and compiled patterns:Generating NimbleParsec ranges
The parser generator nimble_parsec allows a list of codepoint ranges as parameters to several combinators. Unicode Set can generate such ranges:
This can be used as shown in the following example:
kip
Good suggestion and will do for the next version.
tmbb
This is very useful. I can use it to add proper support for unicode names in variable in my Elixir lexer
kip
The Unicode consortium today introduced Unicode version 13.0 that adds 5,390 characters, for a total of 143,859 characters. These additions include four new scripts, for a total of 154 scripts, as well as 55 new emoji characters. As a result there are some updates to ex_unicode and related packages.
ex_unicode version 1.4.0 adds support for Unicode 13. It also add some additional derived categories for detecting quote marks of varying kinds (left, right, double, single, ambidextrous, all). Changelog
unicode_set version 0.5.0 adds support for quote-related unicode sets such as
[[:quote_mark:]],[[:quote_mark_left:]],[[:quote_mark_double:]]and so on. Changelogunicode_guards version 0.2.0 adds guards for quote marks. Changelog
is_quote_mark/1is_quote_mark_left/1is_quote_mark_right/1is_quote_mark_ambidextrous/1is_quote_mark_single/1is_quote_mark_double/1Have fun with Unicode!
kip
ex_unicode_set version 0.6.0 is released today with a primary focus to underpin some upcoming basic
unicode regexcapabilities.Enhancements
Unicode sets are now a
%Unicode.Set{}structAdd
Unicode.Set.Sigilimplementingsigil_uAdd support for
String.CharsandInspectprotocolsBug Fixes
Fixes parsing sets to ignore non-encoded whitespace
Fixes intersection and difference set operations for sets that include string ranges like
{abc}kip
Introducing unicode_string which in this initial release implements the Unicode Case Folding algorithm and also provides a case insensitive string matching function.
Unicode.String.equals_ignoring_case?/2has the same performance as callingString.downcase/1on both arguments and comparing with the added benefit of being Unicode aware.Usage: Unicode.String.equals_ignoring_case?/2
Compares two strings in a case insensitive manner.
Case folding is applied to the two string arguments which are then compared with the
==operator.Arguments
string_aandstring_bare two strings to be comparedtypeis the case folding type to be applied. The alternatives are:full,:simpleand:turkic. The default is:full.Returns
trueorfalseNotes
This function applies the Unicode Case Folding algorithm
The algorithm does not apply any treatment to diacritical marks hence “compare strings without accents” is not part of this function.
Examples
kip
Introducing the
Unicode.Regexmodule that leverages all of the unicode sets supported by unicode_set. It is published on hex as unicode_set version 0.7.0.This means you can use the power of
unicode_setin a regular expressions in addition to guard clauses, compiled patterns and the nimble_parsec combinatorutf8_char/2.This works by pre-processing the regular expression and expanding any unicode sets in place before calling
Regex.compile/2.This functionality allows a developer to more fully use the power of the Unicode database, introspecting blocks, scripts, combining classes and a whole lot more.
Examples
Enhancements
Add
Unicode.Set.character_class/1which returns a string compatible withRegex.compile/2. This supports the idea of expanded Unicode Sets being used in standard Elixir/erlang regular expressions and will underpin implementation of Unicode Transforms in the packageunicode_transformAdd
Unicode.Regex.compile/2to pre-process a regex to expand Unicode Sets and the compile it withRegex.compile/2.Unicode.Regex.compile!/2is also added.Bug Fixes
Have fun with Unicode!
kip
Todays’ update is Unicode String version 0.2.0 which adds an implementation of the Unicode Segmentation Algorithm that support the detection of grapheme, word, line and sentence break boundaries.
Next steps
This work will support the next phase of the text library work on part-of-speech tagging which requires word segmentation as a precursor.
This work also marks another milestone. In order to implement the break algorithm I needed to implement Unicode Regular Expressions. That in turn required implementation of Unicode Sets which, finally, required the implementation of Unicode Properties. The standards are implemented across ex_unicode, unicode_set and unicode_string packages.
Its been a long road and, while not finished, the work is sufficiently advanced to be useful.
Examples
kip
Released today is Unicode Set version 0.11.0 which is primarily a bug fix release . The API, test coverage and overall stability is much improved. A version 1.0 can be expected before end of the year.
Two functional improvements may be useful:
Unicode sets for blank, graphic and print
From time-to-time on the forum there is the question “how can I detect if a string or character is printable”. In Unicode this is not a simple matter but Unicode Regular Expressions provide a portable definition of three unicode sets that may prove useful:
Unicode Regular Expressions
Unicode.Regex.compile/2is now largely compliant with the Unicode Regular Expression standard. It operates by expanding unicode sets before compiling in the usual manner withRegex.compile/2.