Skip to content

Instantly share code, notes, and snippets.

@carlosveliz
Created October 2, 2024 22:56
Show Gist options
  • Save carlosveliz/54aea7071c5229ec7d3fab5747cd44fa to your computer and use it in GitHub Desktop.
Save carlosveliz/54aea7071c5229ec7d3fab5747cd44fa to your computer and use it in GitHub Desktop.
def decode_subject(parts):
subject_parts = []
for part, encoding in parts:
if isinstance(part, bytes):
subject_parts.append(part.decode(encoding if encoding else 'utf-8', errors='replace'))
else:
subject_parts.append(part)
return ''.join(subject_parts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment