Skip to content

Support non-UTF locales. #196

Description

@ant-222

twtxt does not seem to work in non-UTF locales using 8-bit codepages. For example, when invoked as

env LANG=en_US twtxt

it crashes with:

Traceback (most recent call last):
  File "/usr/local/bin/twtxt", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 1077, in main
    with self.make_context(prog_name, args, **extra) as ctx:
         ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 943, in make_context
    self.parse_args(ctx, args)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/click/core.py", line 1641, in parse_args
    echo(ctx.get_help(), color=ctx.color)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/click/utils.py", line 318, in echo
    file.write(out)  # type: ignore
    ~~~~~~~~~~^^^^^
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2019' in position 483: ordinal not in range(256)

Please, consider supporting 8-bit locales, or at least US-ASCII, as the most basic, acessible, and inclusive common-denominator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions