<html>

<head>
    <title>RuneScribe</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="description" content="Transcribe Latin / ASCII to Runes">
    <meta name="keywords" content="runescribe rune runes runic transcribe encode unicode font germanic alphabet">
    <meta name="author" content="Evert Mouw">
    <meta http-equiv="Content-Language" content="EN">
    <script language="javascript">
    function setformfocus(){
        latin.text.select();
        latin.text.focus();
    }
    </script>
    <link rel="stylesheet" href="rune.css">
    <link rel="made" href="mailto:post@evert.net">
</head>

<body onload="setformfocus()">

<h1>Runescribe</h1>

<p>Just type a few letters in the box and click "Scribe". If it doesn't work, you need to install the
<a href="rune_font.html" target=_new>font</a>. If you want to know what this page is all about, please
read the <a href="#explanation">explanation</a> below.

<?php

# check form input
if (isset($_POST['text'])) {
    
$input trim ($_POST['text']);
}
else {
    
$input "For nine nights, I did not sleep!";
}

# form input: font selection
if (isset($_POST['font'])) {
    
$font $_POST['font'];
    switch (
$font) {
        case 
'auto':
            
$fontface '';
            break;
        case 
'Hnias':
            
$fontface ' face="Hnias"';
            break;
        case 
'embedH':
            
$fontface ' class="hnias"';
            break;
        default:
            
$fontface '';
            break;
    }
}
else {
    
$font 'embedH';
    
$fontface ' class="hnias"';
}

# form input: space selection
if (isset($_POST['space'])) {
    
$space $_POST['space'];
}
else {
    
$space 'single_dot';
}

# form input: replace v
if (isset($_POST['v'])) {
    
$v $_POST['v'];
}
else {
    
$v 'off';
}

# form input: replace x
if (isset($_POST['x'])) {
    
$x $_POST['x'];
}
else {
    
$x 'off';
}

# form input: replace x
if (isset($_POST['z'])) {
    
$z $_POST['z'];
}
else {
    
$z 'off';
}

# a "is this selected on the form" function for html selects
function sel ($var$value) {
    if (
$var == $value) {
        print 
'selected ';
    }
    else {
        print 
'';
    }
}

# input form
    
?>

    <form method="POST" action="index.php" name="latin" id="latin">
        <table><tr><td>
            <textarea name="text" id="text" rows="4" cols="30"><?php echo $input?></textarea>
        </td><td>
            <input type="submit" value = "Scribe">
        </td><td>
            <table><tr><td>
                font:
                <select size=1 name="font">
                    <option <?php sel($font'auto'); ?>value="auto">auto<sup>*</sup></option>
                    <option <?php sel($font'Hnias'); ?>value="Hnias">Hnias</option>
                    <option <?php sel($font'embedH'); ?>value="embedH">embedded Hnias</option>
                </select>
                space:
                <select size=1 name="space">
                    <option <?php sel($space'single_dot'); ?>value="single_dot">single dot</option>
                    <option <?php sel($space'none'); ?>value="none">normal space</option>
                </select>
            </td></tr><tr><td>
                <input type="checkbox" <?php if ($v=='on') echo 'CHECKED'?> name="v" id="v"> replace "v" by "w"
                |
                <input type="checkbox" <?php if ($x=='on') echo 'CHECKED'?> name="x" id="x"> replace "x" by "ks"
                <br>
                <input type="checkbox" <?php if ($z=='on') echo 'CHECKED'?> name="z" id="z"> replace "z" by "s"
            </td></tr></table>
        </td></tr></table>
        <br><font color=gray>* font auto: you need a Unicode 3.0 aware browser like Internet Explorer 6.0 (Windows XP)</font>
    </form>

    <?php

# rune unicode values
# reference: http://www.unicode.org/charts/PDF/U16A0.pdf
# unicode hex values MUST USE UPPERCASE becase lowercase letters will be replaced by the regexpr below
$rune = array (
    
"a" => "16A8"# RUNIC LETTER ANSUZ A
    
"b" => "16D2"# RUNIC LETTER BERKANAN BEORC BJARKAN B
    # ??? replace 'c' by 'k'
    #"c" => "16CD", # RUNIC LETTER C
    
"d" => "16DE"# RUNIC LETTER DAGAZ DAEG D
    
"e" => "16D6"# RUNIC LETTER EHWAZ EH E
    
"f" => "16A0"# RUNIC LETTER FEHU FEOH FE F
    
"g" => "16B7"# RUNIC LETTER GEBO GYFU G
    
"h" => "16BA"# RUNIC LETTER HAGLAZ H
    
"i" => "16C1"# RUNIC LETTER ISAZ IS ISS I
    
"j" => "16C3"# RUNIC LETTER JERAN J
    
"k" => "16B2"# RUNIC LETTER KAUNA
    
"l" => "16DA"# RUNIC LETTER LAUKAZ LAGU LOGR L
    
"m" => "16D7"# RUNIC LETTER MANNAZ MAN M
    
"n" => "16BE"# RUNIC LETTER NAUDIZ NYD NAUD N
    
"o" => "16DF"# RUNIC LETTER OTHALAN ETHEL O
    
"p" => "16C8"# RUNIC LETTER PERTHO PEORTH P
    # 'q' was not widely used, maybe replacing it by "kw" would be better
    
"q" => "16E9"# RUNIC LETTER Q
    
"r" => "16B1"# RUNIC LETTER RAIDO RAD REID R
    
"s" => "16CB"# RUNIC LETTER SIGEL LONGBRANCH-SOL S (SOWULO = 16CA, but looks strange)
    
"t" => "16CF"# RUNIC LETTER TIWAZ TIR TYR T
    
"u" => "16A2"# RUNIC LETTER URUZ UR U
    # didn't know 'v' existed... anyway, this one looks like the 16A0 (F) (or use "w" Wunjo)
    
"v" => "16A1"# RUNIC LETTER V
    
"w" => "16B9"# RUNIC LETTER WUNJO WYNN W // --> 01BF = latin letter wynn
    # ??? did this one exist too? or use "ks"? looks nice, though :-)
    
"x" => "16EA"# RUNIC LETTER X
    # doesn't exist: replace by something else: "j" (jera) for Dutch words or for some english words iwaz (Dutch "ei/ij" sound)
    # As I noted in a previous post the J sound was often a soft J, so that Jesus might be pronounced Yesus, or Jon spelled Ion. This is also quite similar to the palatized L sound (as an IPA symbol shown as an upside down 'y'). - http://www.geocities.com/thetropics/island/3634/xrunes.html - Michael Zalar < m_zalar@hotmail.com >
    #"y" => "16", # ---
    # ??? did this one exist too? looks nice, though :-)  Anlosaxon = Algiz, looks like Y (tree)
    
"z" => "16CE"# RUNIC LETTER Z
);

# to lowercase
$output strtolower($input);

# replace user-specified characters
if ($v=='on'$output str_replace ("v""w"$output);
if (
$x=='on'$output str_replace ("x""ks"$output);
if (
$z=='on'$output str_replace ("z""s"$output);

# replace sequences of characters, special characters, etc

    # 1. assign temporary symbols
    
$output str_replace (".""{1}"$output);
    
$output str_replace (",""{1}"$output);
    
$output str_replace (";""{1}"$output);
    
$output str_replace (":""{1}"$output);

    
$output str_replace ("-""{2}"$output);
    
$output str_replace ("!""{2}"$output);
    
$output str_replace ("?""{2}"$output);

    
# 3. remove unneccesary spaces
    
$output str_replace ("{1} ""{1}"$output);
    
$output str_replace ("{2} ""{2}"$output);

    
# 3. the final steps of this phase
    
$output str_replace ("{1}""&#X16EC;"$output); # RUNIC MULTIPLE PUNCTUATION
    
$output str_replace ("{2}""&#X16ED;"$output); # RUNIC CROSS PUNCTUATION

# convert spaces based on user options
    
if ($space == "single_dot") {
        
$output str_replace (" ""&#X16EB;"$output); # spaces to single dots
    
}
    else {
        
$output str_replace (" ""&#X0020;"$output); # normal spaces
    
}

# replace (series of) latin characters by easier latin characters
    
$output str_replace ("eau""o"$output); # French words with eau sounds like the Dutch "o" vowel
    
$output str_replace ("chr""hr"$output); # old Scandinavian (runic) "hr" sounds like Dutch "chr"
    
$output str_replace ("chl""hl"$output); # old Scandinavian (runic) "hl" sounds like Dutch "chl"
    
$output str_replace ("chj""hj"$output); # old Scandinavian (runic) "hj" sounds like Dutch "chj"
    
$output str_replace ("chw""hw"$output); # old Scandinavian (runic) "hw" sounds like Dutch "chw"
    
$output str_replace ("ch""g"$output); # Dutch "ch" sounds like "g" consonant
    
$output str_replace ("cc""ks"$output); # replace "cc" by "ks" (thanks, Hekan Storsdter)
    
$output str_replace ("c""k"$output); # replace "c" by "k"
    
$output str_replace ("y""j"$output); # replace "y" by "j" - SEE COMMENTS ABOVE

# transcribe sounds that consists of two or more latin characters
    
$output str_replace ("ie""&#X16E0;"$output); # RUNIC LETTER EAR, let's use this one for the Dutch "ie" vowel
    
$output str_replace ("ea""&#X16E0;"$output); # RUNIC LETTER EAR, let's use this one for the English "ea" vowel
    
$output str_replace ("ing""&#X16DC;"$output); # RUNIC LETTER INGWAZ, Dutch "ing" sound like in "Inge"
    
$output str_replace ("ng""&#X16DC;"$output); # RUNIC LETTER INGWAZ, Dutch "ng" sound
    
$output str_replace ("nk""&#X16DC;k"$output); # RUNIC LETTER INGWAZ & "K", Dutch "drink" last part = nk = ng + k
    
$output str_replace ("ei""&#X16C7;"$output); # RUNIC LETTER IWAZ EOH, Dutch "ei/ij" vowel
    
$output str_replace ("ij""&#X16C7;"$output); # RUNIC LETTER IWAZ EOH, Dutch "ei/ij" vowel
    # Oes was the o-e dipthong and was pronounced 'o' as in 'Ox' (thanks to J.S.FARLEY <J.S.Farley@lib.hull.ac.uk> )
    
$output str_replace ("oe""&#X16AF;"$output); # RUNIC LETTER OE, i use this for the Dutch "oe" vowel
    
$output str_replace ("th""&#X16A6;"$output); # RUNIC LETTER THURISAZ THURS THORN // --> 00FE = latin small letter thorn

# transcribe numbers
#  Unfortunately, the runic futhark has no signs for numbers.
#  I've seen some historic "solutions" that are unusable.
#  I'm using latin numbers right now.
# CODE BELOW DOESN'T WORK AND GIVES FONT DISPLAY PROBLEMS!!
#for ($ascii=48; $ascii<=57; $ascii++) {
#    $output = str_replace (chr($ascii), "&#X003" . chr($ascii) .  ";", $output);
#}

# CR/LF --> unicode, so line endings will not be destroyed by the "remove all remaining unstranslated chars" later
# (supports DOS/WIN CRLF, MAX CR, UNIX LF)
$output str_replace ("\n""&#X000A;"$output);
$output str_replace ("\r""&#X000D;"$output);

# convert letters to runic
for ($ascii=97$ascii<=122$ascii++) {
    if (
array_key_exists(chr($ascii), $rune)) {
        
$output str_replace (chr($ascii), ("&#X" $rune[chr($ascii)] . ";"), $output);
    }
}

# remove all remaining unstranslated chars
# I make use of the fact that all transscribed chars start with &#X because I use HTML special codes for Unicode chars
# So, all "normal" chars are filtered
    
$expr "(&#X....;)+";
    
$s $output;
    
$o "";
    
$false $output;
    while (
ereg($expr$s$temp)) {
        
$t $temp[0];
        
$start strlen($t) + strpos($s,$t);
        
$length strlen($s);
        
$firstchar substr($s01);
        
$s substr($s$start$length $start);
        
$o .= $t;
        
$false str_replace ($t""$false);
    }
    
$output $o;

# CR/LF --> <br>  (supports DOS/WIN CRLF, MAX CR, UNIX LF)
$output str_replace ("&#X000D;&#X000A;""<br>"$output); # dos/win
$output str_replace ("&#X000A;""<br>"$output); # unix
$output str_replace ("&#X000D;""<br>"$output); #mac

# show nice breaks in input
$input str_replace ("\r\n""<br>"$input); # dos/win
$input str_replace ("\n""<br>"$input); # unix
$input str_replace ("\r""<br>"$input); # mac

# now create input and output arrays, so i can show original latin inline, above, below, or whatever
$input_lines explode ("<br>"$input);
$output_lines explode ("<br>"$output);
$lines=count($input_lines);

# show results
    
echo "\n";
# first, issue warnings
    # no input
    
$len strlen($output);
    if (
$len==0) {
        
?> <font color=red>NOTHING TO TRANSCRIBE</font> <?php
    
}
    
# false inputs
    
$len strlen($false);
    if (
$len 0) {
        
?> <font color=red>Not transcrible: <?php print $false?></font> <br> <?php
    
}
# now show me the runes
for ($i=0$i<$lines$i++){
    
?>
    <!-- line <?php echo $i?> -->
    <font size=4>
        <?php echo $input_lines[$i] . "\n"?>
    </font>
    <br>
    <div<?php echo $fontface ?>>
        <font size=7 color=brown<?php echo $fontface ?>>
        <?php echo $output_lines[$i] . "\n"?>
        </font>
    </div>
    <br>
<?php
echo "\n";
}
?>

<a name="#explanation"><h2>Explanation</h2></a>

<p>The Germanic priests of old used their own writing system called "runes". It was derived of the Etruskian alphabet,
which is also the ancestor of the Roman (Latin) alphabet which we use today and is often called the Western alphabet.
<a href="runes_more.html" target=_new>Click here to learn more about runes.</a></p>

<p>Now you can see the old alphabet (or more correctly: Futhark, after the first seven characters of their "alphabet") in action
by just typing a sentence in the box below and then click on "Scribe". You can copy and paste the runes into a Unicode compatible
editor like Word. Oh, you only see some stupid boxes? Then you need a font which supports the Unicode runic characters. Go to the
<a href="rune_font.html" target=_new>font download page</a> now! Or, for quick and easy results, select the "embedded" font.</p>

<p>Runes are taken from a few different Futharks. I try to conform to the Unicode mapping as close as possible.
This results in a "Futhark" for modern usage, for example with <a href="../folkspraak/">Folkspraak</a>.
See the mapping picture below.</p>

<p>Please note that this is a transcriber, not a translator. This online tool can transcribe Latin characters into runes. It uses
unicode to encode the runic characters. Some combinations of latin characters will be replaced by only one rune because the runic
futhark comes with a different character to sound scheme. See the <a href="mapping.html">mapping table</a>!</p>

<p>Also available for download: a <a href="keyb_map.html" target=_new>keyboard mapping for Windows 2000 / XP (OLD VERSION FOR DUTCH)</a></p>

<p><b>Limitations</b>: No special chars, numbers, and so on. No handling of all long vowels.
<b>Optimized for <a href="../folkspraak/">Folkspraak</a>, but gives good results for English and Dutch too.</b></p>

<!-- google ads -->
<center>
<script type="text/javascript" src="google.js"></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</center>
<br>

<h2>About</h2>

<font color=blue><p><i>Latin (ascii) --> Runic (unicode), a PHP learn project by Evert Mouw, The Netherlands<br>
transcribe engine version: 2004-08-08 | <a href="index.phps">source</a> | <a href="changes.txt">changelog</a><br>
RuneScribe, Copyright © 2004 <a href="http://www.evertmouw.nl/">Evert Mouw</a> &lt; <a href="mailto:post@evert.net">post@evert.net</a> &gt;</i></p></font>

</body>

</html>