Skip to content

Commit

Permalink
Fixes twoolie#144: use mutf8
Browse files Browse the repository at this point in the history
  • Loading branch information
Netherwhal authored and OpenBagTwo committed Feb 9, 2024
1 parent 69d707b commit aeac65b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 21 deletions.
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"
]
]
)

0 comments on commit aeac65b

Please sign in to comment.