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
- Automatic encoding detection
Installation
pip install pykm3-codec
Usage
Basic Usage - Automatic language detection
import codecs
import pykm3_codec
# Western text
text = "PIKACHU used THUNDERBOLT!"
encoded = text.encode('pykm3')
decoded = encoded.decode('pykm3')
print(f"Original: {text}")
print(f"Encoded (hex): {encoded.hex(' ')}")
print(f"Decoded: {decoded}")
# Japanese text - automatic detection
jp_text = "ピカチュウの 10まんボルト!"
encoded = jp_text.encode('pykm3')
decoded = encoded.decode('pykm3')
print(f"Original: {jp_text}")
print(f"Encoded (hex): {encoded.hex(' ')}")
print(f"Decoded: {decoded}")
⚠ WARNING For decoding to japanese is recommended to use directly the "pykm3jap" codec, in most cases the automatic detection works but it can fail in some edge cases, specially when encoding short words/bytearrays.
# Automatic language detection won't work
# because all byte values are also in the western dictionary
encoded = b"\x0B\x08\x27" # さくら (sakura 🌸)
decoded = encoded.decode('pykm3') # Output: 'ÎËú'
decoded = encoded.decode('pykm3jap') # Output: 'さくら'
# This works because byte 4A is not in the western dictionary
encoded = b"\x0B\x08\x27\xE2\x4A" # さくらんぼ (sakuranbo 🍒)
decoded = encoded.decode('pykm3') # Output: 'さくらnぼ'
For example: in bytes to japanese: "A2 A3 A4 A5" == "1234" (fullwidth numbers) in bytes to western: "A2 A3 A4 A5" == "1234" and "1234" != "1234"
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pykm3_codec-0.5.0.tar.gz.
File metadata
- Download URL: pykm3_codec-0.5.0.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e0b5d29918371a0200aec399bc102ac2f705c0edf8d1050261eae13e282c3ac
|
|
| MD5 |
d6fc2cf02aed357760979125915fdab8
|
|
| BLAKE2b-256 |
da3ecfdbb8e2bde93003490c2492bbeb84878ee31fa0b7597560644c85e502dd
|
Provenance
The following attestation bundles were made for pykm3_codec-0.5.0.tar.gz:
Publisher:
python-publish.yml on FrogCosmonaut/pykm3-codec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pykm3_codec-0.5.0.tar.gz -
Subject digest:
6e0b5d29918371a0200aec399bc102ac2f705c0edf8d1050261eae13e282c3ac - Sigstore transparency entry: 178683217
- Sigstore integration time:
-
Permalink:
FrogCosmonaut/pykm3-codec@a52d14c2772800bbd6cf48c5775ca4d9d524cbda -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/FrogCosmonaut
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a52d14c2772800bbd6cf48c5775ca4d9d524cbda -
Trigger Event:
release
-
Statement type:
File details
Details for the file pykm3_codec-0.5.0-py3-none-any.whl.
File metadata
- Download URL: pykm3_codec-0.5.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcb4fa169f32dc074cf52417be781a45964f850dff8d5d125c6d91fcfcc8aeb6
|
|
| MD5 |
ac744bf82a62858af0de3bed1b7bf8c8
|
|
| BLAKE2b-256 |
9866f480dd5d94e0bb629e3e3c7dba9f6573666c99a62148e8f240cb8aa45f47
|
Provenance
The following attestation bundles were made for pykm3_codec-0.5.0-py3-none-any.whl:
Publisher:
python-publish.yml on FrogCosmonaut/pykm3-codec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pykm3_codec-0.5.0-py3-none-any.whl -
Subject digest:
bcb4fa169f32dc074cf52417be781a45964f850dff8d5d125c6d91fcfcc8aeb6 - Sigstore transparency entry: 178683220
- Sigstore integration time:
-
Permalink:
FrogCosmonaut/pykm3-codec@a52d14c2772800bbd6cf48c5775ca4d9d524cbda -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/FrogCosmonaut
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a52d14c2772800bbd6cf48c5775ca4d9d524cbda -
Trigger Event:
release
-
Statement type: