- Joined
- Oct 2, 2014
- Messages
- 1,115
- Reaction score
- 833
Hi all,
Spent an hour digging and found this for us all. It seems to only convert text strings from C9U files, but it's start, no?
Attached is a compile and below is the source. Credits to Brouznouf.
Instructions
1) Download and place this .exe in a folder - View attachment c9udecode.zip.
2) This is a console app, so it runs via command line only.
3) Place any C9U file you want in the same folder as c9udecode.exe
4) Run the .exe like this:
0 = Decode, 1 = Encode
NOTE: When encoding, you need to have the _translate_file.txt document for the file in that same location as well as the .new.c9u file.
Source:
Spent an hour digging and found this for us all. It seems to only convert text strings from C9U files, but it's start, no?
Attached is a compile and below is the source. Credits to Brouznouf.
Instructions
1) Download and place this .exe in a folder - View attachment c9udecode.zip.
2) This is a console app, so it runs via command line only.
3) Place any C9U file you want in the same folder as c9udecode.exe
4) Run the .exe like this:
Code:
c9udecode.exe 0 filenamehere
0 = Decode, 1 = Encode
NOTE: When encoding, you need to have the _translate_file.txt document for the file in that same location as well as the .new.c9u file.
Source:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Int32 mode;
//First Args the Mode
mode = Int32.Parse(args[0]);
//Second Args the C9U File
String c9uName = args[1];
byte testByte;
Int32 textSize;
FileStream c9u = File.Open(c9uName + ".c9u", FileMode.Open);
FileStream translateFile = File.Open(c9uName + "_translate_file.txt", FileMode.Create);
FileStream newC9u = File.Open(c9uName + ".new.c9u", FileMode.Create);
StreamReader lineReadFile = null;
if (mode != 0)
{
lineReadFile = File.OpenText(c9uName + "_line_file.txt");
}
BinaryWriter tWriter = new BinaryWriter(translateFile);
BinaryReader c9uReader = new BinaryReader(c9u, Encoding.Unicode);
BinaryWriter c9uWriter = new BinaryWriter(newC9u, Encoding.Unicode);
//On recherche une occurent de BaseFont
while (c9uReader.BaseStream.Position < c9uReader.BaseStream.Length)
{
testByte = c9uReader.ReadByte();
if (mode != 0) {
c9uWriter.Write(testByte);
}
if (testByte == 0x09 && ((c9uReader.BaseStream.Position + 12) < c9uReader.BaseStream.Length))
{
if (mode == 0) {
c9uReader.ReadBytes(3);
} else {
c9uWriter.Write(c9uReader.ReadBytes(3));
}
Int64 baseFont = c9uReader.ReadInt64();
if (mode != 0) {
c9uWriter.Write(baseFont);
}
if (baseFont == 8389765503978266946)
{
if (mode == 0)
{
c9uReader.ReadByte();
textSize = c9uReader.ReadInt32();
if (textSize > 0)
{
//c9uReader.ReadChar();
String text = new String(c9uReader.ReadChars(textSize));
//c9uReader.ReadChar();
tWriter.Write(text.ToCharArray());
tWriter.Write('\n');
}
}
else
{
c9uWriter.Write(c9uReader.ReadByte());
textSize = c9uReader.ReadInt32();
if (textSize > 0)
{
c9uReader.ReadChars(textSize);
String newText = lineReadFile.ReadLine();
c9uWriter.Write(newText.Length + 1);
c9uWriter.Write(newText.ToCharArray());
c9uWriter.Write('\0');
}
}
}
else
{
if (mode != 0)
{
c9uWriter.BaseStream.Seek(-11, SeekOrigin.Current);
}
c9uReader.BaseStream.Seek(-11, SeekOrigin.Current);
}
}
if (testByte == 0x0c && ((c9uReader.BaseStream.Position + 15) < c9uReader.BaseStream.Length))
{
if (mode == 0)
{
c9uReader.ReadBytes(3);
}
else
{
c9uWriter.Write(c9uReader.ReadBytes(3));
}
String baseFont = new String(c9uReader.ReadChars(12));
if (mode != 0)
{
c9uWriter.Write(baseFont.ToCharArray());
}
if (baseFont.Equals("BaseFontS12", StringComparison.InvariantCultureIgnoreCase))
{
if (mode == 0)
{
textSize = c9uReader.ReadInt32();
if (textSize > 0)
{
//c9uReader.ReadChar();
String text = new String(c9uReader.ReadChars(textSize));
//c9uReader.ReadChar();
tWriter.Write(text.ToCharArray());
tWriter.Write('\n');
}
}
else
{
c9uWriter.Write('\0');
textSize = c9uReader.ReadInt32();
if (textSize > 0)
{
c9uReader.ReadChars(textSize);
String newText = lineReadFile.ReadLine();
c9uWriter.Write(newText.Length + 1);
c9uWriter.Write(newText.ToCharArray());
c9uWriter.Write('\0');
}
}
}
else
{
if (mode != 0)
{
c9uWriter.BaseStream.Seek(-14, SeekOrigin.Current);
}
c9uReader.BaseStream.Seek(-14, SeekOrigin.Current);
}
}
}
c9uReader.Close();
}
}
}
Attachments
You must be registered for see attachments list