tinyunicodeblock 1.3
A tiny utility to get the Unicode block of a character
License: MIT
Requires Python: >=3.7
Keywords: unicode,unicode block,unicode character,block,character block,unicode utility

<img src="./logo.png" width=55 height=55 align="right"/>

# tinyunicodeblock
> A tiny utility to get the Unicode block of a character

[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://black.readthedocs.io/en/stable/)
[![Pylint](https://img.shields.io/badge/pylint-10.00/10.00-ffbf48)](https://pylint.pycqa.org/en/latest/)
[![License](https://img.shields.io/gitlab/license/whoatemybutter/tinyunicodeblock)](https://spdx.org/licenses/MIT.html)
[![PyPi](https://img.shields.io/pypi/v/tinyunicodeblock)](https://pypi.org/project/tinyunicodeblock/)
[![Pipeline status](https://gitlab.com/whoatemybutter/tinyunicodeblock/badges/master/pipeline.svg)](https://gitlab.com/whoatemybutter/tinyunicodeblock/-/commits/master)  

This module provides only one ability that is absent from the built-in module [`unicodedata`](https://docs.python.org/3/library/unicodedata.html).
<br/>
It contains one function, `block()`, which returns the name of a
[Unicode block](https://www.unicode.org/faq/blocks_ranges.html) that a character belongs to.

You may also access basic Unicode block information by getting items from `BLOCKS_BYNAME`.

## Table of contents
- [📦 Installation](#-installation)
- [🛠 Usage](#-usage)
- [📰 Changelog](#-changelog)
- [📜 License](#-license)

---

## 📦 Installation

`tinyunicodeblock` is available on PyPi. 
It requires a Python version of **at least 3.7.0.** and depends on **no packages**.

To install with pip:
```shell
python -m pip install tinyunicodeblock
```

To install through Git:
```shell
python -m pip install git+https://gitlab.com/whoatemybutter/tinyunicodeblock.git
```

---

## 🛠 Usage

Only one function is publicly available, `block(character)`.
It will return the name of a Unicode block that `character` belongs to.

Block ranges are also available in the `BLOCKS_BYNAME` dictionary.

```python
>>> import tinyunicodeblock
>>> tinyunicodeblock.block("a")
'Basic Latin'
>>> tinyunicodeblock.block("\ufdfd")
'Arabic Presentation Forms-A'
>>> tinyunicodeblock.block("\ue845")
'Private Use Area'
>>> tinyunicodeblock.BLOCKS_BYNAME["Basic Latin"]
(0, 127)
```

### CSUR Support
Since v1.2, tinyunicodeblocks contains support for the [ConScript Unicode Registry (CSUR)](https://www.evertype.com/standards/csur/).

It is available through the variables `CSUR` and `CSUR_BYNAME`.
The function `block()` will optionally include CSUR blocks in its results if the argument `include_csur=True` is passed to it.

```python
>>> tinyunicodeblock.block("\ue845", include_csur=True)
'Dni'
>>> tinyunicodeblock.block("\ue400", include_csur=True)
'Niskloz'
>>> tinyunicodeblock.block("\uf800", include_csur=True)
'Private Use Area'
```

> tinyunicodeblocks **does not** contain support for the [Under-ConScript Unicode Registry (UCSUR)](https://www.kreativekorp.com/ucsur/).
---

## 📰 Changelog

The changelog is at [CHANGELOG.md](CHANGELOG.md).

---

## 📜 License

`tinyunicodeblock` v1.2 and above is licensed under
[MIT](https://spdx.org/licenses/MIT.html).

`tinyunicodeblock` v1.1 and below is licensed under
[GNU General Public License 3.0 or later](https://spdx.org/licenses/GPL-3.0-or-later.html).