Replace using table... (command Script/Replace using table...)


Translhextion can use standard Thingy Tables to find and replace encoded text in a file. In the dialog you can choose whether you want to "Optimize" the bytes of the find and replace strings (see below) and you can select the search and replace directions.

NOTE: Because of the nature of Thingy Tables, all searches using tables are CASE SENSITIVE.

In addition to replacing individual values, you can replace all occurrences prior to or following the current selection by choosing the appropriate button under "Replace all..."

What is the difference between enabling and disabling "Optimize bytes"?

The answer to this question requires a good understanding of Thingy tables and DTE (Dual Tile Encoding). You may also want to read about MTE (Multiple Tile Encoding). The answer, in short, is as follows:

NOTE: In the following explanation, where braces ' { ' and ' } ' are used they represent the default value of the separated-byte left enclosure & right enclosure characters which can be specified in Options/Preferences... You must use the characters specified in this setting while using any table-related command!

"Optimize bytes" disabled:

The search and replace strings are parsed through the Thingy table with each byte translated literally. Each character literal is translated into its equivalent character literal in the table without considering DTE, MTE, or multi-byte values and each byte literal of the form {X} is translated into it's equivalent multi-character-byte literal using DTE and MTE.

Example:

If I want to search for or replace "Crystal" in Final Fantasy 2 (US), it happens to be encoded in two forms, the first with all character literals (7-bytes) and the second using DTE (4-bytes). As you can see, byte-literals must be used to find and replace the DTE version of "Crystal".

FIND STRING STRING FOUND BYTES
Crystal "Crystal" 7-bytes
C{ry}{st}{al} "Crystal" 4-bytes

REPLACE STRING STRING FOUND BYTES
Crystal "Crystal" 7-bytes
C{ry}{st}{al} "Crystal" 4-bytes


Lets say I want to search for or replace "Crew" instead. It cannot be found using this setting without typing in byte-literals because the only encoding of it uses DTE (3-bytes). Because of this, without using byte-literals, a 4-byte version would be replaced if "Crew" was entered as the replace string.
FIND STRING STRING FOUND BYTES
Crew N/A 0-bytes
C{re}w "Crew" 3-bytes

REPLACE STRING STRING FOUND BYTES
Crew "Crew" 4-bytes
C{re}w "Crew" 3-bytes


Finally, if I want to find an MTE value such as "Cecil" I MUST enter the byte-literal to find it. If a byte-literal is not used in the replace string then each character literal is translated and used instead.

FIND STRING STRING FOUND BYTES
Cecil N/A 0-bytes
{Cecil} "Cecil" 2-bytes

REPLACE STRING STRING FOUND BYTES
Cecil "Cecil" 5-bytes
{Cecil} "Cecil" 2-bytes

"Optimize bytes" enabled:

The search and replace strings are parsed through the Thingy table and DTE, MTE, & multi-byte replacements are made where possible. DTE, MTE, & multi-byte byte-literals CAN still be used if desired.

Example:

If I want to search for or replace "Crystal" in Final Fantasy 2 (US), it happens to be encoded in two forms, the first with all character literals (7-bytes) and the second using DTE (4-bytes). In this case, the DTE version is found or replaced with or without typing in byte-literals.
FIND STRING STRING FOUND BYTES
Crystal "Crystal" 4-bytes
C{ry}{st}{al} "Crystal" 4-bytes

REPLACE STRING STRING FOUND BYTES
Crystal "Crystal" 4-bytes
C{ry}{st}{al} "Crystal" 4-bytes

*NOTE: This setting CANNOT be used to find or replace the 7-byte version of "Crystal" at all which is why the other setting is available.

Lets say I want to search for or replace "Crew" (DTE, 3-bytes) instead. It be found or replaced with or without typing in byte-literals using this setting.
FIND STRING STRING FOUND BYTES
Crew "Crew" 3-bytes
C{re}w "Crew" 3-bytes

REPLACE STRING STRING FOUND BYTES
Crew "Crew" 3-bytes
C{re}w "Crew" 3-bytes

Finally, if I want to find an MTE value such as "Cecil" I can enter the byte-literal to find it or I can just search for the string itself. The same holds true for the replace string.
FIND STRING STRING FOUND BYTES
Cecil "Cecil" 2-bytes
{Cecil} "Cecil" 2-bytes

REPLACE STRING STRING FOUND BYTES
"Cecil" "Cecil" 2-bytes
{Cecil} "Cecil" 2-bytes

The reason "Optimize bytes" is recommended is because *MOST* game data is usually optimized using DTE, MTE, & multi-byte values if they are present at all. This means that most of the time you are looking for a string that is fewer bytes than the number of characters you typed. This also means that most of the time you want to replace data in the fewest possible bytes (DTE, MTE, MBV) as well. The only time this setting isn't useful is when the string you are searching for COULD have used DTE, MTE, or a multi-byte value but didn't OR you specifically don't want to you apply DTE, MTE, or multi-byte values to your replace string even though you can.