Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #144: use mutf8 #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_size = 2
indent_style = space

[*.py]
indent_size = 4
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Note: OS-specific or editor-specific config files should be set in a global ignore file.
# Use: git config --global core.excludesfile
*.pyc
.DS_Store
/.idea/
*.pyc
6 changes: 4 additions & 2 deletions nbt/nbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from collections import MutableMapping, MutableSequence, Sequence
import sys

import mutf8

_PY3 = sys.version_info >= (3,)
if _PY3:
unicode = str
Expand Down Expand Up @@ -360,10 +362,10 @@ def _parse_buffer(self, buffer):
read = buffer.read(length.value)
if len(read) != length.value:
raise StructError()
self.value = read.decode("utf-8")
self.value = mutf8.decode_modified_utf8(read)

def _render_buffer(self, buffer):
save_val = self.value.encode("utf-8")
save_val = mutf8.encode_modified_utf8(self.value)
length = TAG_Short(len(save_val))
length._render_buffer(buffer)
buffer.write(save_val)
Expand Down
32 changes: 16 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
from nbt import VERSION

setup(
name = 'NBT',
version = ".".join(str(x) for x in VERSION),
description = 'Named Binary Tag Reader/Writer',
author = 'Thomas Woolford',
author_email = '[email protected]',
url = 'http://github.com/twoolie/NBT',
license = open("LICENSE.txt").read(),
long_description = open("README.txt").read(),
packages = ['nbt'],
classifiers = [
name='NBT',
version=".".join(str(x) for x in VERSION),
description='Named Binary Tag Reader/Writer',
author='Thomas Woolford',
author_email='[email protected]',
url='http://github.com/twoolie/NBT',
license=open("LICENSE.txt").read(),
long_description=open("README.txt").read(),
packages=['nbt'],
install_requires=['mutf8'],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Games/Entertainment",
"Topic :: Software Development :: Libraries :: Python Modules"
]
]
)