`pathlib` Wrapper with **UTF-8 first** and **LineFeed first**, based on `pathlib3x`.
Project description
IceSpringPathLib
pathlib
Wrapper with UTF-8 first and LineFeed first, based on pathlib3x
.
Official sites
- Home: https://baijifeilong.github.io/2022/01/08/ice-spring-path-lib/index.html
- Github: https://github.com/baijifeilong/IceSpringPathLib
- PyPI(IceSpringPathLib): https://pypi.org/project/IceSpringPathLib
- PyPI(pathlib3x): https://pypi.org/project/pathlib3x
Features
UTF-8
is the default encoding, even onWindows
LineFeed
is the default new-line format, even onWindows
- All
pathlib3x
features
Install
- PyPI:
pip install IceSpringPathLib
Usage
import pathlib
import tempfile
import chardet
import IceSpringPathLib
tempfile.mktemp()
filename = tempfile.mktemp()
text = "Common\n常\nSense\n识\n天地玄黄"
print("Original text:", repr(text))
pathlib.Path(filename).write_text(text)
encoding = chardet.detect(open(filename, mode="rb").read())["encoding"]
print("\nWritten text by pathlib:", repr(open(filename, newline="", encoding=encoding).read()))
print("Written encoding by pathlib:", encoding)
IceSpringPathLib.Path(filename).write_text(text)
encoding = chardet.detect(open(filename, mode="rb").read())["encoding"]
print("\nWritten text by IceSpringPathLib:", repr(open(filename, newline="", encoding=encoding).read()))
print("Written encoding by IceSpringPathLib:", encoding)
Example Output
Original text: 'Common\n常\nSense\n识\n天地玄黄'
Written text by pathlib: 'Common\r\n常\r\nSense\r\n识\r\n天地玄黄'
Written encoding by pathlib: GB2312
Written text by IceSpringPathLib: 'Common\n常\nSense\n识\n天地玄黄'
Written encoding by IceSpringPathLib: utf-8
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
IceSpringPathLib-1.1.0.tar.gz
(18.2 kB
view hashes)
Built Distribution
Close
Hashes for IceSpringPathLib-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4715f6b740d114c5c1c8ee2332953b105a95ad1f589cb1b38be22493150df053 |
|
MD5 | 0d31bdb36ebe6978f070412d958150a2 |
|
BLAKE2b-256 | 1e75dce5aa44657d76ca20168ca728ca89bb2c0824f35cea60294ab7dbf5f147 |