Create your AI Cum Slut -70% for Mother's Day
x

Tutorial Tool Method to run KiriKiri games without locale emulation

Surgy

Member
Modder
Apr 23, 2018
393
1,660
Many KiriKiri games show this when you run them without a correct locale:
crash_due_to_shift_jis.png
There is always the option to run locale emulation of some sort or switching locale to Japanese yet, if you translated a game or want some kind of permanent solution, that's pretty inconvenient. But there is another, less known, method after you extracted the game using or some other tool.

The method is as simple as converting all .ks (unscrambled plain-text) and .tjs game scripts to UTF-16LE with BOM signature. The tools to convert the scripts automatically are attached to this message; the first needs .NET v4.6.2 , which usually comes with Win 10+ already, and the second needs Python installed.

Notes:
  • Some games contain additional text or csv files in Shift-JIS/cp932 encoding, in which case they may also need to be found and re-encoded, see the provided .cmd batch script that re-encodes .ks/.tjs for how to do this.
  • The .NET tool will not help if some of the game files were originally encoded in UTF-8 without a BOM signature in the first bytes, in which case re-encoding must be done manually on a per-file basis or with the Python tool.

To do it, unpack the files to the extracted game folder and run the included reencode.cmd for the .NET tool or textutf16y.py for the Python tool.

Edit: Just in case I added alternative Python tool to do the same, but with detecting files using no-BOM UTF-8 and some other encodings. The file extensions to process are hard-coded in the .py text there.
Edit 1: Password for the first archive with the .NET tool is f95zone since the site misdetects it as a virus otherwise.
Edit 2: Removed encoding detector from Python version because it's unreliable anyway. It now tries to check predefined encodings.
 
Last edited:
  • Like
Reactions: Cruxiz and avarokun

--hi

Member
Modder
May 30, 2021
128
1,291
Thanks for this awesome tool! It will help me a lot with my translations, cheers !
 

Surgy

Member
Modder
Apr 23, 2018
393
1,660
Recently I found a game that used an old version of csvParser.dll that couldn't read UTF-16LE CSV files.
Turns out there is a hack for Override.tjs that makes it work:
JavaScript:
Plugins.link("csvParser.dll");
with(global.CSVParser) {
    // HACK: use native KiriKiri processing for CSVs instead
    .parseStorage = function(filename, utf8) {
        this.parse(
            [].load(filename).join('\n')
        );
    };
    // for UTF-16LE BOM CSVs this works
    .initStorage = function(filename) {
        this.StorageBuffer = [].load(filename);
        this.StorageBuffer.reverse();
    };
    // parse it as we go
    .getNextLine = function() {
        if (this.StorageBuffer !== void) {
            var retData = this.StorageBuffer.pop();
            if (retData !== void) return retData.split('\t');
        }
    };
};
 

Jair4x

New Member
Jan 14, 2024
4
1
What about games that have 2 different startup.tjs inside data.xp3?
An example could be Karenai Sekai to Owaru Hana.
 

Surgy

Member
Modder
Apr 23, 2018
393
1,660
What about games that have 2 different startup.tjs
And the problem with that is...?
If you mean the inability to create patch.xp3 for them, there are 3 ways:
  • Recreate the entire data.xp3 or whatever and create a / patch with the original;
  • Rename the one that's loaded manually and change all reference calls to the file like Scripts.execStorage("... .tjs");, KAGLoadScript("... .tjs"); etc. and add the changed files too;
  • Distribute the modded game unpacked or add instructions to apply the patch to the unpacked game.
 
Last edited:
  • Like
Reactions: Jair4x