Skip to main content

Unicode Babel

Unicode Babel is a easy to use python package for generating random unicode code-points/characters.

It's ideal for use in your tests or tools, Allowing you to quickly identify bugs and data processing issues.

  • Easy to use iterator for repeated tests
  • Unicode Planes 0, 1 and 2
  • Python 3.6+
  • Free to use and open source

Getting started:

To install:

pip install unicode-babel

This code:

from unicode_babel import tools, filters

genny = tools.CodePointGenerator()

for point in genny.random_codepoints(10, filters.filter_out_if_no_name):
    print(point)

Will output 10 random unicode code-points from the Basic Multilingual Plane, filtered to ensure only valid named code-points are returned.:

ᓆ
ᗡ
ꋛ
販
ۅ
䶣
楨
蟷
䔉
ݥ

As these are valid characters from valid code-points you can use these anywhere that clams to accept text.

If you want to really put the cat among the pigeons try this code:

from unicode_babel import *

genny = tools.CodePointGenerator()

for point in genny.random_codepoints(10, filters.filter_in_if_no_name):
    print(point)

...it will fail badly, as the code-points filtered-in can not be encoded, the codepoints don't map to a 'character'. The error might look something like this:

Traceback (most recent call last):
  File "tryout.py", line 6, in <module>
    print(point)
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud8b4' in position 0: surrogates not allowed

But this nonetheless might be useful in unit testing etc.

Or you can get individual code-points and them use them with other tools, for example Selenium Webdriver:

from unicode_babel import tools, filters
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

browser = webdriver.Chrome()
browser.get("https://www.google.com")

data_genny = tools.CodePointGenerator()
unusual_char = data_genny.get_random_codepoint(filters.filter_out_if_no_name)

search_box = browser.find_element_by_name("q")
search_box.send_keys(unusual_char + Keys.RETURN)

Assuming you have Chromedriver (Webdriver) in your path, that should open Google and search for a random character.

Testing

If you have downloaded the code from GitHub and wish to run the unit tests:

python -m unittest discover -v tests

License:

Copyright © 2023 Peter Houghton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release files for unicode-babel 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unicode-babel 0.1.7
File Size Uploaded
unicode_babel-0.1.7.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unicode-babel 0.1.7
File Interpreter ABI Platform
unicode_babel-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / unicode_babel-0.1.7.tar.gz

Download URL unicode_babel-0.1.7.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
403579e99ab605c1cac424f7a6cf2762ee132fd442e5231fea1272aa3e474499
BLAKE2b-256 checksum
How to use checksums
cfad67b3a22d6db36478c3933251d3ba5d3533df83d583ceeb5ec06f8914f36c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.2

Release files / unicode_babel-0.1.7-py3-none-any.whl

Download URL unicode_babel-0.1.7-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51f609b4491313af094a9731c7275fefbc9c62b474b75850dc1a505233239e0a
BLAKE2b-256 checksum
How to use checksums
2a3d73a8589a8d9de1eff805eb43318301e4faad44cc2857bb221367246881e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page