Skip to content

Instantly share code, notes, and snippets.

@rhee
Last active January 12, 2026 02:09
Show Gist options
  • Select an option

  • Save rhee/a504e2fcad420ef5c9bee9e1f2046004 to your computer and use it in GitHub Desktop.

Select an option

Save rhee/a504e2fcad420ef5c9bee9e1f2046004 to your computer and use it in GitHub Desktop.
#
# recover broken string (double decoded 'IBM PC OEM')
# https://gist.github.com/rhee/a504e2fcad420ef5c9bee9e1f2046004
#
import sys
for broken_snippet in sys.stdin:
# 1. Encode back to the 'IBM-PC' raw bytes
# 2. Decode using CP949 (Korean)
try:
recovered = broken_snippet.encode('cp437').decode('cp949')
#print(f"Recovered Text: {recovered}")
sys.stdout.write(recovered)
except Exception as e:
print(f"Error: {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment