{"id":20119590,"url":"https://github.com/box/rotunicode","last_synced_at":"2025-08-20T03:31:39.249Z","repository":{"id":57462724,"uuid":"12013966","full_name":"box/rotunicode","owner":"box","description":"Python library for converting between a string of ASCII and Unicode chars maintaining readability","archived":false,"fork":false,"pushed_at":"2019-01-29T03:31:06.000Z","size":132,"stargazers_count":77,"open_issues_count":1,"forks_count":21,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-12-07T05:30:17.265Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/box.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-10T01:50:11.000Z","updated_at":"2023-09-08T16:41:22.000Z","dependencies_parsed_at":"2022-09-05T17:21:32.392Z","dependency_job_id":null,"html_url":"https://github.com/box/rotunicode","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/box%2Frotunicode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/box%2Frotunicode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/box%2Frotunicode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/box%2Frotunicode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/box","download_url":"https://codeload.github.com/box/rotunicode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230388131,"owners_count":18217755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T19:16:13.669Z","updated_at":"2024-12-19T06:09:55.605Z","avatar_url":"https://github.com/box.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"rotunicode\n==========\n\n.. image:: http://opensource.box.com/badges/active.svg\n    :target: http://opensource.box.com/badges\n\n.. image:: https://travis-ci.org/box/rotunicode.png?branch=master\n    :target: https://travis-ci.org/box/rotunicode\n\n.. image:: https://coveralls.io/repos/box/rotunicode/badge.png\n    :target: https://coveralls.io/r/box/rotunicode\n\n.. image:: https://img.shields.io/pypi/v/rotunicode.svg\n    :target: https://pypi.python.org/pypi/rotunicode\n\n.. image:: https://img.shields.io/pypi/dm/rotunicode.svg\n    :target: https://pypi.python.org/pypi/rotunicode\n\n\nRotUnicode is a Python library that can convert a string containing ASCII\ncharacters to a string with non-ASCII characters without losing readability.\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e 'Hello World!'.encode('rotunicode')\n    Ĥȅľľő Ŵőŕľď!\n    \u003e\u003e\u003e 'Ĥȅľľő Ŵőŕľď!'.decode('rotunicode')\n    Hello World!\n\nIn the above example, the 'Hello World' string has all ASCII characters.\nEncoding it with RotUnicode gives you 'Ĥȅľľő Ŵőŕľď' which reads like\n'Hello World' but has all non-ASCII characters.\n\n\nWhy is this named RotUnicode?\n-----------------------------\n\nRotUnicode stands for rotate-to-unicode. Or rotten-unicode for those who have\nnightmares about Unicode. It was inspired by Rot13.\n\n\nSupported Characters\n--------------------\n\nRotUnicode converts lower case and upper case characters of the English\nalphabet and digits 0 to 9 to non-ASCII characters. All characters that are\noutside this range are left as is.\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e 'हेलो World!'.encode('rotunicode')\n    हेलो Ŵőŕľď!\n    \u003e\u003e\u003e 'हेलो Ŵőŕľď!'.decode('rotunicode')\n    हेलो World!\n\n\nInstallation\n------------\n\nTo install, simply:\n\n.. code-block:: console\n\n    pip install rotunicode\n\n\nUse\n---\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e from rotunicode import ruencode\n    \u003e\u003e\u003e ruencode('Hello World!')\n    Ĥȅľľő Ŵőŕľď!\n    \u003e\u003e\u003e rudecode('Ĥȅľľő Ŵőŕľď!')\n    Hello World!\n\n\nAs a Codec\n----------\n\nIn Python 2, RotUnicode can also be used as a codec, but it must first\nbe registered with the codecs library. This allows python to know what\nfunctions to call to encode or decode a string using RotUnicode.\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e import codecs\n    \u003e\u003e\u003e from rotunicode import RotUnicode\n    \u003e\u003e\u003e codecs.register(RotUnicode.search_function)\n    \u003e\u003e\u003e 'Hello World!'.encode('rotunicode')\n    Ĥȅľľő Ŵőŕľď!\n\n\nCommand Line\n------------\n\nInstalling RotUnicode also includes a command line tool.\n\n.. code-block:: console\n\n    $ rotunicode \"Hello World\"\n    Ĥȅľľő Ŵőŕľď!\n    $ rotunicode -d \"Ĥȅľľő Ŵőŕľď!\"\n    Hello World!\n    $ echo \"Hello World!\" \u003e hello.txt\n    $ rotunicode -f hello.txt\n    Ĥȅľľő Ŵőŕľď!\n    $ cat hello.txt | rotunicode -f\n    Ĥȅľľő Ŵőŕľď!\n\n\nWhy should I use RotUnicode?\n----------------------------\n\nRotUnicode it extremely helpful in testing because it reduces the friction for\ndevelopers to test with non-ASCII strings. Imagine for example that you have a\nclass to represent a contact for your address book application:\n\n.. code-block:: python\n\n    class Contact(object):\n\n        def __init__(self, first_name, last_name):\n            super(Contact, self).__init__()\n            self.first_name = first_name\n            self.last_name = last_name\n\n        def display_name(self):\n            return '{} {}'.format(self.first_name, self.last_name)\n\nMost developers would test this as follows:\n\n.. code-block:: python\n\n    from unittest import TestCase\n    from contact import Contact\n\n    class ContactTests(TestCase):\n\n        def test_display_name(self):\n            contact = Contact('John', 'Doe’)\n            self.assertEqual('John Doe', contact.display_name()))\n\nThis test is good. But it is going to miss catching problems in the code with\nnon-ASCII characters. Requiring developers to remember how to type non-ASCII\ncharacters is not practical. With RotUnicode, this is super easy:\n\n.. code-block:: python\n\n    from unittest import TestCase\n    from contact import Contact\n\n    class ContactTests(TestCase):\n\n        def test_display_name_with_ascii_name(self):\n            contact = Contact(u'John', u'Doe')\n            self.assertEqual(u'John Doe', contact.display_name())\n\n        def test_display_name_with_non_ascii_name(self):\n            contact = Contact(ruencode(u'John'), ruencode(u'Doe'))\n            self.assertEqual(ruencode(u'John Doe'), contact.display_name())\n\n\nThis is an example of a bug in Python\n(`issue18695 \u003chttp://bugs.python.org/issue18695\u003e`_) with non-ASCII characters -\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e import os, errno\n    \u003e\u003e\u003e name = 'foo'.encode('rotunicode')\n    \u003e\u003e\u003e os.mkdir(name)\n    \u003e\u003e\u003e print(name)\n    ƒőő\n    \u003e\u003e\u003e os.path.exists(name)\n    True\n    \u003e\u003e\u003e os.statvfs(name)\n    Traceback (most recent call last):\n      File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n    UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2:\n    ordinal not in range(128)\n\n\nContribute\n----------\n\nSee `CONTRIBUTING \u003chttps://github.com/box/rotunicode/blob/master/CONTRIBUTING.rst\u003e`_.\n\n\nSetup\n~~~~~\n\nCreate a virtual environment and install packages:\n\n.. code-block:: console\n\n    mkvirtualenv rotunicode\n    pip install -r requirements-dev.txt\n\n\nTesting\n~~~~~~~\n\nRun all tests using:\n\n.. code-block:: console\n\n    tox\n\nThe tox tests include code style checks via pep8 and pylint.\n\nThe tox tests are configured to run on Python 2.7, 3.4, 3.5, 3.6, 3.7,\nand PyPy2.7 (version 5.10).\n\n\nCopyright and License\n---------------------\n\n::\n\n Copyright 2019 Box, Inc. All rights reserved.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbox%2Frotunicode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbox%2Frotunicode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbox%2Frotunicode/lists"}