# Tools for Slash-Hash Packed Data Format
[![PyPI](https://img.shields.io/pypi/pyversions/shpdf-tools?style=for-the-badge&logo=pypi&logoColor=white)](https://pypi.org/project/shpdf-tools/)
## Introduction
Slash-Hash Packed Data Format (SHPDF) is a legacy data format. The original data and specification is missing. This project aims to provide tools to process SHPDF data. Please note that our implementation is based on personal conjuncture and may not be accurate.
## User guide
### 1. Obtain some data
- The packed data contains some unreadable characters
- The packed data should be encoded in `big5` or `cp950`
- The packed data extension does not matter
- The packed data should look like this (in cp950 encoding)
```plaintext
?坼#ADte 101662/06/23\#AuID 10\#AuNm 6鄭成功\#ArID 10\#VerN 10\#Hdr1 240版~1~鄭成功,在台灣\#Hdr2 0\#Hdr3 0\#ALno 12\#Word 228\#PbID 0?怕K?B
0版~1~鄭成功,在台灣
︻記者鄭成功/報導︼▓︵國姓爺︶。◆
?
```
### 2. Install our tools
- Using `pip`
```shell
pip install shpdf-tools
```
- Using `poetry`
```shell
poetry add shpdf-tools
```
### 3. Use our tools to process the packed data
- Decode and encode the packed data
```python
from shpdf_tools.decode import decode_dict
from shpdf_tools.encode import encode_json
from io import BytesIO
packed_data = b'\xc8\xa9\\#ADte 101662/06/23\\#AuID 10\\#AuNm 6\xbeG\xa6\xa8\xa5\\\\#ArID 10\\#VerN 10\\#Hdr1 24\xa2\xaf\xaa\xa9\xa1\xe3\xa2\xb0\xa1\xe3\xbeG\xa6\xa8\xa5\\\xa1A\xa6b\xa5x\xc6W\\#Hdr2 0\\#Hdr3 0\\#ALno 12\\#Word 228\\#PbID 0\xc8\xa9\xc8K\xc8B\r\n\xa2\xaf\xaa\xa9\xa1\xe3\xa2\xb0\xa1\xe3\xbeG\xa6\xa8\xa5\\\xa1A\xa6b\xa5x\xc6W\r\n\xa1@\xa1k\xb0O\xaa\xcc\xbeG\xa6\xa8\xa5\\\xa1\xfe\xb3\xf8\xbe\xc9\xa1l\xf9\xfe\xa1_\xb0\xea\xa9m\xb7\xdd\xa1`\xa1C\xa1\xbb\r\n\x00'
decoded_packed_data = decode_dict(BytesIO(packed_data))
# Check the decoded data
assert decoded_packed_data['ADte'] == '1662/06/23'
assert decoded_packed_data['PbID'] == ''
assert decoded_packed_data['Data'] == '0版~1~鄭成功,在台灣\r\n\u3000︻記者鄭成功/報導︼▓︵國姓爺︶。◆\r\n'
# Encode the decoded data
encoded_packed_data = encode_json(decoded_packed_data)
# Check the encoded data
assert encoded_packed_data == b'{"ADte":"1662/06/23","AuID":"0","AuNm":"\xe9\x84\xad\xe6\x88\x90\xe5\x8a\x9f","ArID":"0","VerN":"0","Hdr1":"\xef\xbc\x90\xe7\x89\x88\xef\xbd\x9e\xef\xbc\x91\xef\xbd\x9e\xe9\x84\xad\xe6\x88\x90\xe5\x8a\x9f\xef\xbc\x8c\xe5\x9c\xa8\xe5\x8f\xb0\xe7\x81\xa3","Hdr2":"","Hdr3":"","ALno":"2","Word":"28","PbID":"","Data":"\xef\xbc\x90\xe7\x89\x88\xef\xbd\x9e\xef\xbc\x91\xef\xbd\x9e\xe9\x84\xad\xe6\x88\x90\xe5\x8a\x9f\xef\xbc\x8c\xe5\x9c\xa8\xe5\x8f\xb0\xe7\x81\xa3\\r\\n\xe3\x80\x80\xef\xb8\xbb\xe8\xa8\x98\xe8\x80\x85\xe9\x84\xad\xe6\x88\x90\xe5\x8a\x9f\xef\xbc\x8f\xe5\xa0\xb1\xe5\xb0\x8e\xef\xb8\xbc\xe2\x96\x93\xef\xb8\xb5\xe5\x9c\x8b\xe5\xa7\x93\xe7\x88\xba\xef\xb8\xb6\xe3\x80\x82\xe2\x97\x86\\r\\n"}'
```
## License
- [MIT License](./LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/AsherJingkongChen/shpdf-tools/blob/main/README.md",
"name": "shpdf-tools",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "data,decode,encode,format,language,parse",
"author": "AsherJingkongChen",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/24/1c/c4da75a97545faaa1a0503fc07adf55511b8999a3d7a42e3ef03bcb80f49/shpdf_tools-0.1.7.tar.gz",
"platform": null,
"description": "# Tools for Slash-Hash Packed Data Format\n\n[![PyPI](https://img.shields.io/pypi/pyversions/shpdf-tools?style=for-the-badge&logo=pypi&logoColor=white)](https://pypi.org/project/shpdf-tools/)\n\n## Introduction\n\nSlash-Hash Packed Data Format (SHPDF) is a legacy data format. The original data and specification is missing. This project aims to provide tools to process SHPDF data. Please note that our implementation is based on personal conjuncture and may not be accurate.\n\n## User guide\n\n### 1. Obtain some data\n\n- The packed data contains some unreadable characters\n- The packed data should be encoded in `big5` or `cp950`\n- The packed data extension does not matter\n- The packed data should look like this (in cp950 encoding)\n\n```plaintext\n?\u577c#ADte 101662/06/23\\#AuID 10\\#AuNm 6\u912d\u6210\u529f\\#ArID 10\\#VerN 10\\#Hdr1 24\uff10\u7248\uff5e\uff11\uff5e\u912d\u6210\u529f\uff0c\u5728\u53f0\u7063\\#Hdr2 0\\#Hdr3 0\\#ALno 12\\#Word 228\\#PbID 0?\u6015K?B\n\uff10\u7248\uff5e\uff11\uff5e\u912d\u6210\u529f\uff0c\u5728\u53f0\u7063\n\u3000\ufe3b\u8a18\u8005\u912d\u6210\u529f\uff0f\u5831\u5c0e\ufe3c\u2593\ufe35\u570b\u59d3\u723a\ufe36\u3002\u25c6\n?\n```\n\n### 2. Install our tools\n\n- Using `pip`\n\n ```shell\n pip install shpdf-tools\n ```\n\n- Using `poetry`\n\n ```shell\n poetry add shpdf-tools\n ```\n\n### 3. Use our tools to process the packed data\n\n- Decode and encode the packed data\n\n ```python\n from shpdf_tools.decode import decode_dict\n from shpdf_tools.encode import encode_json\n from io import BytesIO\n\n packed_data = b'\\xc8\\xa9\\\\#ADte 101662/06/23\\\\#AuID 10\\\\#AuNm 6\\xbeG\\xa6\\xa8\\xa5\\\\\\\\#ArID 10\\\\#VerN 10\\\\#Hdr1 24\\xa2\\xaf\\xaa\\xa9\\xa1\\xe3\\xa2\\xb0\\xa1\\xe3\\xbeG\\xa6\\xa8\\xa5\\\\\\xa1A\\xa6b\\xa5x\\xc6W\\\\#Hdr2 0\\\\#Hdr3 0\\\\#ALno 12\\\\#Word 228\\\\#PbID 0\\xc8\\xa9\\xc8K\\xc8B\\r\\n\\xa2\\xaf\\xaa\\xa9\\xa1\\xe3\\xa2\\xb0\\xa1\\xe3\\xbeG\\xa6\\xa8\\xa5\\\\\\xa1A\\xa6b\\xa5x\\xc6W\\r\\n\\xa1@\\xa1k\\xb0O\\xaa\\xcc\\xbeG\\xa6\\xa8\\xa5\\\\\\xa1\\xfe\\xb3\\xf8\\xbe\\xc9\\xa1l\\xf9\\xfe\\xa1_\\xb0\\xea\\xa9m\\xb7\\xdd\\xa1`\\xa1C\\xa1\\xbb\\r\\n\\x00'\n\n decoded_packed_data = decode_dict(BytesIO(packed_data))\n\n # Check the decoded data\n assert decoded_packed_data['ADte'] == '1662/06/23'\n assert decoded_packed_data['PbID'] == ''\n assert decoded_packed_data['Data'] == '\uff10\u7248\uff5e\uff11\uff5e\u912d\u6210\u529f\uff0c\u5728\u53f0\u7063\\r\\n\\u3000\ufe3b\u8a18\u8005\u912d\u6210\u529f\uff0f\u5831\u5c0e\ufe3c\u2593\ufe35\u570b\u59d3\u723a\ufe36\u3002\u25c6\\r\\n'\n\n # Encode the decoded data\n encoded_packed_data = encode_json(decoded_packed_data)\n\n # Check the encoded data\n assert encoded_packed_data == b'{\"ADte\":\"1662/06/23\",\"AuID\":\"0\",\"AuNm\":\"\\xe9\\x84\\xad\\xe6\\x88\\x90\\xe5\\x8a\\x9f\",\"ArID\":\"0\",\"VerN\":\"0\",\"Hdr1\":\"\\xef\\xbc\\x90\\xe7\\x89\\x88\\xef\\xbd\\x9e\\xef\\xbc\\x91\\xef\\xbd\\x9e\\xe9\\x84\\xad\\xe6\\x88\\x90\\xe5\\x8a\\x9f\\xef\\xbc\\x8c\\xe5\\x9c\\xa8\\xe5\\x8f\\xb0\\xe7\\x81\\xa3\",\"Hdr2\":\"\",\"Hdr3\":\"\",\"ALno\":\"2\",\"Word\":\"28\",\"PbID\":\"\",\"Data\":\"\\xef\\xbc\\x90\\xe7\\x89\\x88\\xef\\xbd\\x9e\\xef\\xbc\\x91\\xef\\xbd\\x9e\\xe9\\x84\\xad\\xe6\\x88\\x90\\xe5\\x8a\\x9f\\xef\\xbc\\x8c\\xe5\\x9c\\xa8\\xe5\\x8f\\xb0\\xe7\\x81\\xa3\\\\r\\\\n\\xe3\\x80\\x80\\xef\\xb8\\xbb\\xe8\\xa8\\x98\\xe8\\x80\\x85\\xe9\\x84\\xad\\xe6\\x88\\x90\\xe5\\x8a\\x9f\\xef\\xbc\\x8f\\xe5\\xa0\\xb1\\xe5\\xb0\\x8e\\xef\\xb8\\xbc\\xe2\\x96\\x93\\xef\\xb8\\xb5\\xe5\\x9c\\x8b\\xe5\\xa7\\x93\\xe7\\x88\\xba\\xef\\xb8\\xb6\\xe3\\x80\\x82\\xe2\\x97\\x86\\\\r\\\\n\"}'\n ```\n\n## License\n\n- [MIT License](./LICENSE)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Tools for Slash-Hash Packed Data Format",
"version": "0.1.7",
"project_urls": {
"Homepage": "https://github.com/AsherJingkongChen/shpdf-tools/blob/main/README.md",
"Repository": "https://github.com/AsherJingkongChen/shpdf-tools.git"
},
"split_keywords": [
"data",
"decode",
"encode",
"format",
"language",
"parse"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "329b7c8927cd8a3a0d3584334ce96ea86ba18eddacc5f89316d18ac9eb68aac5",
"md5": "0d63f174788b9ce9686e88cf54f4c92c",
"sha256": "24176ec8b90a9e8457201e83b7920b3f888ff6413221e745f0371bed6f5e4009"
},
"downloads": -1,
"filename": "shpdf_tools-0.1.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0d63f174788b9ce9686e88cf54f4c92c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 7268,
"upload_time": "2024-03-09T12:35:12",
"upload_time_iso_8601": "2024-03-09T12:35:12.989754Z",
"url": "https://files.pythonhosted.org/packages/32/9b/7c8927cd8a3a0d3584334ce96ea86ba18eddacc5f89316d18ac9eb68aac5/shpdf_tools-0.1.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "241cc4da75a97545faaa1a0503fc07adf55511b8999a3d7a42e3ef03bcb80f49",
"md5": "26ccb3ffc8bac5bc35c28c034e22c6b1",
"sha256": "b88adf7907763499e7579ccaf4433e4ac8b5568e5361295e1e768f1eb7b64e32"
},
"downloads": -1,
"filename": "shpdf_tools-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "26ccb3ffc8bac5bc35c28c034e22c6b1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 5402,
"upload_time": "2024-03-09T12:35:14",
"upload_time_iso_8601": "2024-03-09T12:35:14.526006Z",
"url": "https://files.pythonhosted.org/packages/24/1c/c4da75a97545faaa1a0503fc07adf55511b8999a3d7a42e3ef03bcb80f49/shpdf_tools-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-09 12:35:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AsherJingkongChen",
"github_project": "shpdf-tools",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "shpdf-tools"
}