Skip to main content

Pokémon Generation III Text Codec

Project description

PyKM3 Codec

A Python codec for encoding and decoding text in Pokémon Generation III games (Ruby, Sapphire, Emerald, FireRed, LeafGreen).

Features

  • Full support for Western and Japanese character sets
  • Implementation as a standard Python codec

Installation

pip install pykm3-codec

Usage

Basic Usage - Registered codec

import pykm3_codec

# Register the codecs
pykm3_codec.register()

# Western text
text = "KADABRA used PSYCHIC!"
encoded = text.encode('pykm3')
decoded = encoded.decode('pykm3')
print(f"Original: {text}")
print(f"Encoded : {encoded.hex(' ')}")
print(f"Decoded : {decoded}")

# Japanese text
jp_text = "ユンゲラー ハ サイコキネシス ヲ ツカッタ!"
encoded = jp_text.encode('pykm3jap')
decoded = encoded.decode('pykm3jap')
print(f"Original: {jp_text}")
print(f"Encoded : {encoded.hex(' ')}")
print(f"Decoded : {decoded}")

Output:

Original: KADABRA used PSYCHIC!
Encoded : c5 bb be bb bc cc bb 00 e9 e7 d9 d8 00 ca cd d3 bd c2 c3 bd ab ff
Decoded : KADABRA used PSYCHIC!
Original: ユンゲラー ハ サイコキネシス ヲ ツカッタ!
Encoded : 75 7e 8a 77 ae 00 6a 00 5b 52 5a 57 68 5c 5d 00 7d 00 62 56 a0 60 ab ff
Decoded : ユンゲラー ハ サイコキネシス ヲ ツカッタ!

Using the Codec Directly

from pykm3_codec import WesternPokeTextCodec, JapanesePokeTextCodec

# Western text
western_codec = WesternPokeTextCodec()
text = "Hello, Trainer!"
encoded = western_codec.encode(text)
decoded = western_codec.decode(encoded)

# Japanese text
japanese_codec = JapanesePokeTextCodec()
jp_text = "こんにちは、トレーナー!"
encoded = japanese_codec.encode(jp_text)
decoded = japanese_codec.decode(encoded)

Reading/Writing Files

import pykm3_codec
import codecs

# Write game script to a file
with codecs.open('script.bin', 'w', 'pykm3') as f:
    f.write("PROF. OAK: Hello there!\nWelcome to the world of POKéMON!")

# Read game script from a file
with codecs.open('script.bin', 'r', 'pykm3') as f:
    content = f.read()
    print(content)

Character Support

Western Characters

  • Basic Latin alphabet (uppercase and lowercase)
  • Numbers (0-9)
  • Common punctuation
  • Special characters (♂, ♀, etc.)
  • Accented characters (é, ü, etc.)

Japanese Characters

  • Hiragana
  • Katakana
  • Full-width numbers and punctuation
  • Full-width Latin alphabet

License

GNU GENERAL PUBLIC LICENSE Version 3

Acknowledgements

This codec was inspired by the documentation and research on Gen III Pokémon text format by various ROM hacking communities. Specially bulbapedia: https://bulbapedia.bulbagarden.net/wiki/Character_encoding_(Generation_III)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykm3_codec-0.5.1.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pykm3_codec-0.5.1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file pykm3_codec-0.5.1.tar.gz.

File metadata

  • Download URL: pykm3_codec-0.5.1.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pykm3_codec-0.5.1.tar.gz
Algorithm Hash digest
SHA256 8690df8dd42373a78ef7fe73057fb6ab380836eff6f62a89d30582cb78338af0
MD5 a631f3734cdeb5aad54a6ea7cadbb5a5
BLAKE2b-256 e9ad30cec0b10ddbcfde4811c67e54e70881d3ab6a3f697d396f7d7afa7cf619

See more details on using hashes here.

Provenance

The following attestation bundles were made for pykm3_codec-0.5.1.tar.gz:

Publisher: python-publish.yml on FrogCosmonaut/pykm3-codec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pykm3_codec-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: pykm3_codec-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pykm3_codec-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21cedab45c9d89f7b89d67e86b6bd57272ca1dda27420d51151c361afb87cd96
MD5 01877c06e66528e4965427807d6f8dc6
BLAKE2b-256 9c4cec75d69f5b2549726588bf199cb505c395206f97fcceac30900a528293ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pykm3_codec-0.5.1-py3-none-any.whl:

Publisher: python-publish.yml on FrogCosmonaut/pykm3-codec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page