| 1476 | |
| 1477 | |
| 1478 | class 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 | |
| 1498 | class _StrEnumField: |
no outgoing calls
no test coverage detected