Java "Unicode"

Admin User, created Nov 04. 2023
         
package player.unicode;
import transpiler.unicode.Compress;
/**
* Compressed General Category and Numeric Value: Compressor
* <p>
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies AG makes no warranties
* regarding the provided information. XLOG Technologies AG assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies AG.
* <p>
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies AG. If the company was not the originator of some
* excerpts, XLOG Technologies AG has at least obtained the right to
* reproduce, change and translate the information.
* <p>
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
* <p>
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
* <p>
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies AG.
*/
public class Unicode {
/**
* Compress and print.
*/
public static void main(String[] args) {
long ts = System.currentTimeMillis();
Compress.compress();
statistics(ts);
dump();
}
/**
* Print the two pools and the entry point.
*/
private static void dump() {
System.out.print("const pool = [");
for (int i = 0; i < Compress.pool.size(); i++) {
if (i != 0) {
System.out.println(',');
System.out.print(" ");
}
Compress.show(Compress.pool.get(i));
}
System.out.println("];");
System.out.print("const pool2 = [");
for (int i = 0; i < Compress.pool2.size(); i++) {
if (i != 0) {
System.out.println(',');
System.out.print(" ");
}
Compress.show(Compress.pool2.get(i));
}
System.out.println("];");
System.out.print("const buf3 = ");
Compress.show(Compress.buf3.toString());
System.out.println(";");
System.out.println();
System.out.println("function code_property(ch) {");
System.out.println(" return pool[pool2[buf3[ch>>" +
(Compress.PARA_BITS + Compress.BLOCK_BITS) + "]][(ch>>" +
Compress.PARA_BITS + ")&0x" +
Integer.toHexString(Compress.BLOCK_SIZE - 1).toUpperCase() + "]][ch&0x" +
Integer.toHexString(Compress.PARA_SIZE - 1).toUpperCase() + "];");
System.out.println("}");
System.out.println("export function code_type(ch) {");
System.out.println(" return code_property(ch) & 0x1F;");
System.out.println("}");
System.out.println("export function code_numeric(ch) {");
System.out.println(" return (code_property(ch) >> 5) - 1;");
System.out.println("}");
}
/**
* Print some statistics about the compresssion.
*
* @param ts The time stamp before compression was called.
*/
private static void statistics(long ts) {
long ts2 = System.currentTimeMillis();
System.out.println("/**");
System.out.println(" * Compression took " + (ts2 - ts) + " ms");
System.out.println(" * Java Specification Version " + Compress.getVersion());
System.out.println(" *");
int alpha = Compress.pool.size() * Compress.PARA_SIZE;
int beta = Compress.pool2.size() * Compress.BLOCK_SIZE;
int gamma = Compress.MAX_BLOCK;
System.out.println(" * pool.size()*PARA_SIZE= " + alpha);
System.out.println(" * pool2.size()*BLOCK_SIZE= " + beta);
System.out.println(" * MAX_BLOCK= " + gamma);
System.out.println(" * Total= " + (alpha + beta + gamma));
System.out.println(" */");
System.out.println();
}
}