Module refinery.units.encoding.u16
Expand source code Browse git
from __future__ import annotations
from refinery.lib.id import guess_text_encoding
from refinery.units import Unit
class u16(Unit):
"""
Encodes and decodes UTF-16 encoded string data.
"""
def reverse(self, data: bytearray):
return data.decode(self.codec).encode('utf-16LE')
def process(self, data: bytearray):
return data.decode('utf-16').encode(self.codec)
@classmethod
def handles(cls, data):
if encoding := guess_text_encoding(data):
return encoding.step == 2
Classes
class u16-
Encodes and decodes UTF-16 encoded string data.
Expand source code Browse git
class u16(Unit): """ Encodes and decodes UTF-16 encoded string data. """ def reverse(self, data: bytearray): return data.decode(self.codec).encode('utf-16LE') def process(self, data: bytearray): return data.decode('utf-16').encode(self.codec) @classmethod def handles(cls, data): if encoding := guess_text_encoding(data): return encoding.step == 2Ancestors
Subclasses
Class variables
var required_dependenciesvar optional_dependenciesvar console
Methods
def reverse(self, data)-
Expand source code Browse git
def reverse(self, data: bytearray): return data.decode(self.codec).encode('utf-16LE')
Inherited members