Skip to content

Text Functions

SpiredMoth edited this page Jul 24, 2023 · 5 revisions
char* i18n_species(int species);

Translates the National Dex number of a species into it's name in the user's language

  • This string SHOULD NOT be freed or edited! It is a direct pointer to where it is stored in PKSM, so freeing/editing it will result in terrible things happening

Format Conversion

Due to the different generations storing strings in different formats, a few utility functions have been provided for working with strings.

For working with strings in a save file, see the documentation on sav_get_string and sav_set_string in Save Access Functions.

For working with OT name and nickname strings on a Pokémon, see the documentation on pkx_get_value and pkx_set_value in PKX Editing Functions.

char* ucs2_to_utf8(char* data);
char* utf8_to_ucs2(char* data);

Converts strings between UTF8 (like OT is stored in config) and UCS2 (like OT is stored in save files)

  • returned strings must be manually freed
void base64_decode(unsigned char** out, int* outSize, char* data, int size);

Converts a base64 string to binary data. While Pokémon save files don't store data in base64 strings, it is a popular data interchange format for other programs and services.

  • unsigned char** out: A pointer that the converted data's location will be set to. This pointer needs to be manually freed
  • int* outSize: The size of the resulting string.
  • char* data: The base64 string to be converted.
  • int size: The amount of string to be converted.
void base64_encode(char** out, int* outSize, unsigned char* data, int size);

Converts binary data to a base64 string. While Pokémon save files don't store data as base64 strings, it is a popular data interchange format for other programs and services.

  • char** out: A pointer that the resulting string's location will be set to. This pointer needs to be manually freed
  • int* outSize: The size of the resulting string.
  • unsigned char* data: The binary data to be converted.
  • int size: The size of data to be converted.
void bz2_decompress(unsigned char** out, int* outSize, unsigned char* data, int size);

Decompresses BZ2 data

  • unsigned char** out: Pointer for function to set to the decompressed data's memory address. This pointer will need to be manually freed when your script is done working with the decompressed data.
  • int* outSize: Pointer for function to set decompressed data size.
  • unsigned char* data: BZ2 data to be decompressed.
  • int size: Size of data to be decompressed.
void bz2_compress(unsigned char** out, int* outSize, unsigned char* data, int size);

Compresses data using BZ2

  • unsigned char** out: Pointer for function to set to the compressed data's memory address. This pointer will need to be manually freed when your script is done working with the compressed data.
  • int* outSize: Pointer for function to set compressed data size.
  • unsigned char* data: data to be compressed.
  • int size: Size of data to be compressed.