W3C home > Mailing lists > Public > www-style@w3.org > December 2002

Re: css3-lists: Coptic and Ionic Greek

From: Christos Cheretakis <xalkina@otenet.gr>
Date: Mon, 16 Dec 2002 19:27:18 +0200
Message-ID: <3DFE0CF6.9040804@otenet.gr>
To: Web Style Sheets W3C Mailing List <www-style@w3.org>
CC: Ian Hickson <ian@hixie.ch>
Christos Cheretakis wrote:
>   I'm currently working on a simple (& sample) Java class implementing 
> the three algorithm variations. I'll post it to the list when it will be 
> ready.

   As promised, attaching a simple java class that demonstrates the 
three algorithm variations. I double-checked the arrays, but if there's 
any inconsintency, please consider the names of the characters to be 
correct.

>     C/
> 

	C/

-- 
   Λες κι η στάθμη της αγάπης πάει να βρει                          /"\
   Πόσοι κρύβονται στη λάσπη θησαυροί         ASCII Ribbon Campaign \ /
   Πως κοπήκανε στα δάχτυλα οι σταυροί           against HTML email  X
   Γι' ανθρώπων έργα...                     & microsoft attachments / \

/*
 * GreekNumberGenerator.java
 *
 * Created on 16 Δεκέμβριος 2002, 6:15 μμ
 */

/**
 *
 * @author  xalkina
 */
public class GreekNumberGenerator {

    static final String[] ONES_ANCIENT = {
        "alpha",    // U+03B1
        "beta",     // U+03B2
        "gamma",    // U+03B3
        "delta",    // U+03B4
        "epsilon",  // U+03B5
        "stigma",   // U+03DB
        "zeta",     // U+03B6
        "eta",      // U+03B7
        "theta"     // U+03B8
    };
    static final String[] TENS_ANCIENT = {
        "iota",    // U+03B9
        "kappa",   // U+03BA
        "lamda",   // U+03BB
        "mu",      // U+03BC
        "nu",      // U+03BD
        "xi",      // U+03BE
        "omicron", // U+03BF
        "pi",      // U+03C0
        "koppa"    // U+03DF
    };
    static final String[] HUNDREDS_ANCIENT = {
        "rho",     // U+03C1
        "sigma",   // U+03C3
        "tau",     // U+03C4
        "upsilon", // U+03C5
        "phi",     // U+03C6
        "chi",     // U+03C7
        "psi",     // U+03C8
        "omega",   // U+03C9
        "sampi"    // U+03E1
    };

    static final String[] ONES_LOWER_MODERN = {
        "alpha",       // U+03B1
        "beta",        // U+03B2
        "gamma",       // U+03B3
        "delta",       // U+03B4
        "epsilon",     // U+03B5
        "(sigma+tau)", // U+03C3 U+03C4
        "zeta",        // U+03B6
        "eta",         // U+03B7
        "theta"        // U+03B8
    };
    static final String[] TENS_LOWER_MODERN = {
        "iota",       // U+03B9
        "kappa",      // U+03BA
        "lamda",      // U+03BB
        "mu",         // U+03BC
        "nu",         // U+03BD
        "xi",         // U+03BE
        "omicron",    // U+03BF
        "pi",         // U+03C0
        null
    };
    static final String[] HUNDREDS_LOWER_MODERN = {
        "rho",        // U+03C1
        "sigma",      // U+03C3
        "tau",        // U+03C4
        "upsilon",    // U+03C5
        "phi",        // U+03C6
        "chi",        // U+03C7
        "psi",        // U+03C8
        "omega",      // U+03C9
        null
    };

    static final String[] ONES_UPPER_MODERN = {
        "ALPHA",       // U+0391
        "BETA",        // U+0392
        "GAMMA",       // U+0393
        "DELTA",       // U+0394
        "EPSILON",     // U+0395
        "(SIGMA+TAU)", // U+03A3 U+03A4
        "ZETA",        // U+0396
        "ETA",         // U+0397
        "THETA"        // U+0398
    };
    static final String[] TENS_UPPER_MODERN = {
        "IOTA",        // U+0399
        "KAPPA",       // U+039A
        "LAMDA",       // U+039B
        "MU",          // U+039C
        "NU",          // U+039D
        "XI",          // U+039E
        "OMIKRON",     // U+039F
        "PI",          // U+03A0
        null
    };
    static final String[] HUNDREDS_UPPER_MODERN = {
        "RHO",         // U+03A1
        "SIGMA",       // U+03A3
        "TAU",         // U+03A4
        "UPSILON",     // U+03A5
        "PHI",         // U+03A6
        "CHI",         // U+03A7
        "PSI",         // U+03A8
        "OMEGA",       // U+03A9
        null
    };

    static final String LOWER_NUMERAL_SIGN = "(lnsign)"; // U+0375

    static final String NUMERAL_SIGN = "(nsign)"; // U+0374

    public static String generateAncientGreekNumber(int number) {
        String[][] symbols = new String[6][];
        StringBuffer representation = new StringBuffer();

        int current_digit;
        int position;
        int number_copy = number;

        symbols[0] = symbols[3] = ONES_ANCIENT;
        symbols[1] = symbols[4] = TENS_ANCIENT;
        symbols[2] = symbols[5] = HUNDREDS_ANCIENT;

        if (number >= 1000000) {
            return null;
        }

        position = 0;
        do {
            if (position == 3) {
                representation.insert(0, ' ');
            }
            current_digit = number_copy % 10;
            if (current_digit > 0) {
                representation.insert(0, symbols[position][current_digit-1]);
            }
            number_copy /= 10;
            ++position;
        } while (number_copy != 0);

        if (number >= 1000) {
            representation.insert(0, LOWER_NUMERAL_SIGN);
        }

        representation.append(NUMERAL_SIGN);

        return new String(representation);
    }

    public static String generateLowerModernGreekNumber(int number) {
        String[][] symbols = new String[6][];
        StringBuffer representation = new StringBuffer();

        int current_digit;
        int position;
        int number_copy = number;

        symbols[0] = symbols[3] = ONES_LOWER_MODERN;      // could be ONES_ANCIENT
        symbols[1] = symbols[4] = TENS_LOWER_MODERN;      // could be TENS_ANCIENT
        symbols[2] = symbols[5] = HUNDREDS_LOWER_MODERN;  // could be HUNDREDS_ANCIENT

        if (number >= 1000000) {
            return null;
        }

        position = 0;
        do {
            if (position == 3) {
                representation.insert(0, ' ');
            }
            current_digit = number_copy % 10;
            if (current_digit == 9 && (position == 1 || position == 2 || position == 4 || position == 5)) {
                return null;
            }
            if (current_digit > 0) {
                representation.insert(0, symbols[position][current_digit-1]);
            }
            number_copy /= 10;
            ++position;
        } while (number_copy != 0);

        if (number >= 1000) {
            representation.insert(0, LOWER_NUMERAL_SIGN);
        }

        representation.append(NUMERAL_SIGN);

        return new String(representation);
    }

    public static String generateUpperModernGreekNumber(int number) {
        String[][] symbols = new String[6][];
        StringBuffer representation = new StringBuffer();

        int current_digit;
        int position;
        int number_copy = number;

        symbols[0] = symbols[3] = ONES_UPPER_MODERN;
        symbols[1] = symbols[4] = TENS_UPPER_MODERN;
        symbols[2] = symbols[5] = HUNDREDS_UPPER_MODERN;

        if (number >= 1000000) {
            return null;
        }

        position = 0;
        do {
            if (position == 3) {
                representation.insert(0, ' ');
            }
            current_digit = number_copy % 10;
            if (current_digit == 9 && (position == 1 || position == 2 || position == 4 || position == 5)) {
                return null;
            }
            if (current_digit > 0) {
                representation.insert(0, symbols[position][current_digit-1]);
            }
            number_copy /= 10;
            ++position;
        } while (number_copy != 0);

        if (number >= 1000) {
            representation.insert(0, LOWER_NUMERAL_SIGN);
        }

        representation.append(NUMERAL_SIGN);

        return new String(representation);
    }

    public static void main(String[] argv) {
        int number;
        String representation;

        for (int i = 0; i < argv.length; ++i) {
            number = Integer.parseInt(argv[i]);
            System.out.println(number + " is ");

            representation = generateAncientGreekNumber(number);
            System.out.print("ancient-greek: ");
            if (representation != null) {
                System.out.println(" " + representation);
            }
            else {
                System.out.println(" no representation");
            }

            representation = generateLowerModernGreekNumber(number);
            System.out.print("lower-modern-greek: ");
            if (representation != null) {
                System.out.println(" " + representation);
            }
            else {
                System.out.println(" no representation");
            }

            representation = generateUpperModernGreekNumber(number);
            System.out.print("upper-modern-greek: ");
            if (representation != null) {
                System.out.println(" " + representation);
            }
            else {
                System.out.println(" no representation");
            }

            System.out.println("------------------------");
        }
    }
}
Received on Monday, 16 December 2002 12:30:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:18 GMT