Metadata-Version: 2.1
Name: cjkjust
Version: 0.1.2.1
Summary: Having strings containing CJK characters left-, right-justified or centered gracefully.
Home-page: https://github.com/kkew3/cjkjust.git
Author: Kaiwen Wu
Author-email: kps6326@hotmail.com
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Requires-Python: >=2.7
Description-Content-Type: text/markdown
Provides-Extra: allchars
License-File: LICENSE

# cjkjust

Having strings containing CJK characters left-, right-justified or centered gracefully.

## Installation

```
pip install cjkjust
```

## Functions

- `is_wide(char) -> bool`: returns whether a character `char` is wide
- `cjklen(string) -> int`: returns the display width of a `string` containing CJK characters
- `cjkljust(string, width: int, fillbyte=' ')`: has `string` left-justified
- `cjkrjust(string, width: int, fillbyte=' ')`: has `string` right-justified
- `cjkcenter(string, width: int, fillbyte=' ')`: has `string` centered

Caveat: `<TAB>` in `string` ruins the print-out.

## Examples

```python
import cjkjust

# right-justify a column of strings
print(cjkjust.cjkrjust('hello 世界', 20))
print(cjkjust.cjkrjust('你好world', 20))
print(cjkjust.cjkrjust('again and again', 20))
```

## Optional dependency

- [`wcwidth`](https://pypi.org/project/wcwidth/): if installed, 0-width characters will also be well handled in `cjkljust`, `cjkrjust`, and `cjkcenter`. Caveat: installing `wcwidth` implies that `ValueError` will be raised if `<TAB>` is in `string`

It can be installed along with `cjkjust` by:

```
pip install cjkjust[allchars]
```


