MCPcopy Index your code
hub / github.com/secdev/scapy / StrFieldUtf16

Class StrFieldUtf16

scapy/fields.py:1478–1495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1476
1477
1478class StrFieldUtf16(StrField):
1479 def any2i(self, pkt, x):
1480 # type: (Optional[Packet], Optional[str]) -> bytes
1481 if isinstance(x, str):
1482 return self.h2i(pkt, x)
1483 return super(StrFieldUtf16, self).any2i(pkt, x)
1484
1485 def i2repr(self, pkt, x):
1486 # type: (Optional[Packet], bytes) -> str
1487 return plain_str(self.i2h(pkt, x))
1488
1489 def h2i(self, pkt, x):
1490 # type: (Optional[Packet], Optional[str]) -> bytes
1491 return plain_str(x).encode('utf-16-le', errors="replace")
1492
1493 def i2h(self, pkt, x):
1494 # type: (Optional[Packet], bytes) -> str
1495 return bytes_encode(x).decode('utf-16-le', errors="replace")
1496
1497
1498class _StrEnumField:

Calls

no outgoing calls

Tested by

no test coverage detected