home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / drafts / draft_ietf_a_c / draft-ietf-acap-langtag-00.txt < prev    next >
Text File  |  1997-06-24  |  24KB  |  730 lines

  1.  
  2.  
  3.  
  4.  
  5. Internet Draft                                               M. Duerst
  6. <draft-ietf-acap-langtag-00.txt>                  University of Zurich
  7. Expires in six months                                        June 1997
  8.  
  9.  
  10.          Two Alternative Proposals for Language Taging in ACAP
  11.  
  12.  
  13. Status of this Memo
  14.  
  15.    This document is an Internet-Draft.  Internet-Drafts are working doc-
  16.    uments of the Internet Engineering Task Force (IETF), its areas, and
  17.    its working groups. Note that other groups may also distribute work-
  18.    ing documents as Internet-Drafts.
  19.  
  20.    Internet-Drafts are draft documents valid for a maximum of six
  21.    months. Internet-Drafts may be updated, replaced, or obsoleted by
  22.    other documents at any time.  It is not appropriate to use Internet-
  23.    Drafts as reference material or to cite them other than as a "working
  24.    draft" or "work in progress".
  25.  
  26.    To learn the current status of any Internet-Draft, please check the
  27.    1id-abstracts.txt listing contained in the Internet-Drafts Shadow
  28.    Directories on ds.internic.net (US East Coast), nic.nordu.net
  29.    (Europe), ftp.isi.edu (US West Coast), or munnari.oz.au (Pacific
  30.    Rim).
  31.  
  32.  
  33. Abstract
  34.  
  35.    For various computing applications, it is helpful to know the lan-
  36.    guage of the text being processed. This can be the case even if oth-
  37.    erwise only pure character sequences (so-called plain text) are han-
  38.    dled.  From several sides, the need for such a scheme for ACAP has
  39.    been claimed. One specific scheme, called MLSF, has also been pro-
  40.    posed, see draft-ietf-acap-mlsf-01.txt for details.  This document
  41.    proposes two alternatives to MLSF. One alternative is using
  42.    text/enriched-like markup.  The second alternative is using a special
  43.    tag-introduction character.  Advantages and disadvantages of the var-
  44.    ious proposals are discussed. Some general comments about the topic
  45.    of language tagging are given in the introduction.
  46.  
  47.  
  48.  
  49. 1. Introduction
  50.  
  51.    This introduction contains some considerations about language infor-
  52.    mation that should help to better understand why and where language
  53.  
  54.  
  55.  
  56.                           Expires in six months         [Page 1]
  57.  
  58. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  59.  
  60.  
  61.    information can be beneficial. They are intended for general informa-
  62.    tion, and are not directly related to the specifics of the proposals
  63.    made in this document.
  64.  
  65.  
  66. 1.1 Multilingual Text
  67.  
  68.    It is sometimes claimed that text, in order to be multilingual, has
  69.    to contain language information of some kind or another.  This is
  70.    definitely not the case. Multilingual text has existed for centuries
  71.    on paper and other writing materials, and for decades in computers,
  72.    without language information. A huan reader with the necessary lan-
  73.    guage background is always able to understand a multilingual text
  74.    without explicitly being told which language each word or character
  75.    belongs to. In some cases, there may be ambiguities, but this is
  76.    either intended, such as in a pun or joke, it is because the reader
  77.    is not fully familliar with the involved languages, or it is because
  78.    the writer was no precise enough.
  79.  
  80.    The overwhelming majority of characters always has been used in vari-
  81.    ous languages, and a character per se therefore cannot be associated
  82.    to a single language. This likewise applies to words (and sometimes
  83.    even phrases) out of context.
  84.  
  85.  
  86. 1.2 Language Taging
  87.  
  88.    While the human reader does not need special language information,
  89.    such information can be useful for the purpose of automatic process-
  90.    ing of various kinds. These in particular include indexing and
  91.    searching, text-to-speech conversion, other conversion operations
  92.    such as case conversion and transliteration, spelling and grammar
  93.    checks, and high-quality typography.
  94.  
  95.    Two other operations are frequently mentionned as benefiting from
  96.    language information: Sorting and machine translation. However, in
  97.    the case of sorting, this has to occur according to the expectations
  98.    of the viewer, frequently encapsulated as a so-called locale. The
  99.    language of each of the items being sorted is not relevant. In the
  100.    case of machine translation, the knowledge and effort to translate a
  101.    language is by magnitudes higher than the knowledge needed to decide
  102.    whether a certain word or sentence belong to a given language.
  103.    Explicit language information is therefore of marginal importance.
  104.    This also applies to other operations, such as text-to-speech conver-
  105.    sion, in particular for high quality and for languages with a compli-
  106.    cated relationship between spelling and pronounciation (such as
  107.    English).
  108.  
  109.  
  110.  
  111.  
  112.                           Expires in six months         [Page 2]
  113.  
  114. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  115.  
  116.  
  117. 1.2 CJK(V) Glyph Disambiguation
  118.  
  119.    The reason one hears most for the necessity of language information
  120.    is the need to disambiguate CJK(V) ideographic glyphs, i.e. to select
  121.    specific typographic variants of certain ideographic characters,
  122.    variants which can differ somewhat between Chinese (simplified or
  123.    traditional), Japanese, Korean, or classical Vietnamese.  Some such
  124.    distinctions can indeed be made by using language information to
  125.    indicate typographic tradition.  However, the usefullness of this
  126.    approach is limited by a series of facts that are not all very widely
  127.    known:
  128.  
  129.    -  Even if a glyph is by mistake taken from another typographic tra-
  130.       dition, readability, in particular in context, is never affected.
  131.  
  132.    -  In running text, the differences resulting from the use of differ-
  133.       ent fonts (e.g. Song-style font vs. Mincho-style) as well as from
  134.       different weights of the same font are much more visible than the
  135.       differences resulting from glyph variant details.
  136.  
  137.    -  In many fonts, glyphs vary, for sund aestetic and historic rea-
  138.       sons, to a similar or higher degree than that exhibited in the
  139.       "reference" glyphs for each typographic tradition as given in [ISO
  140.       10646]. This applies to print, but even more to handwriting.
  141.  
  142.    -  National standards explicitly or implicitly allow for a certain
  143.       variance of glyph shapes. In particular, the newest edition of the
  144.       basic Japanese character standard, JIS X 0208-1997 [JIS1997],
  145.       explicitly mentionnes a large number of permitted variants (pp.
  146.       12-22) for Mincho fonts only. It also explicitly allows a list of
  147.       29 much wider-reaching variants as a consequence of some unfortu-
  148.       nate changes to the standard in 1983 (p. 22).
  149.  
  150.    -  Long-standing typographic practice does not use special glyph
  151.       variants for representing short inclusions of foreign origin (such
  152.       as names of persons, places, or institutions) in native text.
  153.  
  154.    -  Some glyph variants are seen by some persons as explicit proper-
  155.       ties of their names. Identifying a name by a particular language
  156.       and assuming that this implies a particular typographic tradition
  157.       can in some cases lead to the desired result. However, the results
  158.       cannot be guaranteed due to design differences between different
  159.       fonts used in the same typographic tradition, and due to the fact
  160.       that even national standards glyph standards considerably unify
  161.       glyph variants.
  162.  
  163.    All the above facts clearly limit the usefullness of language tags
  164.    for CJK(V) glyph variant selection. Language taging should therefore
  165.  
  166.  
  167.  
  168.                           Expires in six months         [Page 3]
  169.  
  170. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  171.  
  172.  
  173.    not be advertized as a comprehensive solution to the various problems
  174.    of CJK(V) glyph variant selection.
  175.  
  176.  
  177. 2. A Text/Enriched-like Notation for Language Tags (TELT)
  178.  
  179.    This section specifies a text/enriched-like notation for language
  180.    tags, leading to a format simmilar to text/enriched. It can be used
  181.    with any character encoding that contains the necessary subset of the
  182.    US-ASCII character repertoire.
  183.  
  184.    Language tags are of the form "<LANG=xxxxx>" where xxxxx is a lan-
  185.    guage tag as defined in [RFC1766], with all letters written in upper
  186.    case. No whitespace of any kind is allowed between "<" and ">".
  187.  
  188.    Language alternatives are started by "<ALTLANG>". Again, no whites-
  189.    pace is allowed between "<" and ">".
  190.  
  191.    The use of the character sequences "<LANG=" and "<ALTLANG>" is not
  192.    allowed in the text itself. Code to convert from this notation to
  193.    MLSF and back and to test for false positives in plain text search is
  194.    given in an appendix.
  195.  
  196.  
  197. 3. Language Tags using a Start Tag Character (STLT)
  198.  
  199.    This method of language taging is only useable with character encod-
  200.    ings that can represent the BMP of the Universal Character Set
  201.    [ISO10646]. For the purpose of illustration, the character PILCROW
  202.    SIGN (paragraph sign, U+00B6) is used as the tag start character. It
  203.    would be preferable to officially define a currently unused code
  204.    point exclusively for this purpose, but such a definition is outside
  205.    of the scope of this document and outside of the scope of IETF work.
  206.    If this solution is seriously considered for adoption by the IETF for
  207.    use in some of it's protocols, a request for such a codepoint should
  208.    be made through the appropriate channels.
  209.  
  210.    For possible future expansions, tag syntax after the start tag char-
  211.    acter is kept very simple and general. Tags are defined to start with
  212.    a tag start character, contain only characters from the US-ASCII
  213.    repertoire (U+0021 through U+007E, inclusive), excluding the tag end
  214.    character, and end with a tag end character. The character "#" is
  215.    choosen as a tag end character.
  216.  
  217.    Language tags proper are formed by a start tag character, a language
  218.    tag according to [RFC1766], with all letters in upper case, and a "#"
  219.    as an end tag character, without any intervening white space.
  220.  
  221.  
  222.  
  223.  
  224.                           Expires in six months         [Page 4]
  225.  
  226. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  227.  
  228.  
  229.    Language alternatives are marked by a sequence of a start tag charac-
  230.    ter, a "%", and a "#" as an end tag character, again without any
  231.    intevening white space. Code to convert from this notation to MLSF
  232.    and back and to test for false positives in plain text search is
  233.    given in an appendix.
  234.  
  235.  
  236. 4. Conformance
  237.  
  238.    Conforming protocols using either of the solutions proposed above
  239.    MUST clearly define in which places they do so, and in which places
  240.    they don't. If there are other mechanisms in the procotol that can be
  241.    used for language taging, these mechanisms should be considered and
  242.    used. In particular, storing language information separate from the
  243.    actual text is beneficial in many cases because it allows the proto-
  244.    col to treat language information and language alternatives in a way
  245.    appropriate to the protocol, i.e. only selecting and transmitting
  246.    language alternatives desired by the client, and so on.
  247.  
  248.    Conforming protocols and their implementations MUST at all costs
  249.    avoid that language tags leak into parts of the protocol where they
  250.    are not allowed or into other channels where they are not allowed. In
  251.    the absence of specific information to the countrary, a protocol or
  252.    implementation MUST assume that another protocol or implementation
  253.    does not allow language tags.
  254.  
  255.    In interfaces to protocols and formats that use other ways of lan-
  256.    guage taging (for an example HTML, see [RFC2070]), conforming proto-
  257.    cols SHOULD convert language tags appropriately or MAY eliminate
  258.    them.
  259.  
  260.    If text including language tags as defined in this document leaks
  261.    outside the protocol positions where it is explicitly allowed, it
  262.    should be treated in the same way other text is treated, with no spe-
  263.    cial processing.
  264.  
  265.  
  266. 5. Discussion
  267.  
  268.    Two alternative forms for language taging have been proposed in this
  269.    document. Because they are very simillar, only one of them should
  270.    finally be choosen. Compared to [MLSF], their main advantages are
  271.    that they can be used with character encodings other than UTF-8, that
  272.    they are easily distinguished from UTF-8 by implementors and users,
  273.    and that they are advantageous in case of debuging and initial string
  274.    composition.
  275.  
  276.    The MLSF proposal has a number of interesting properties that makes
  277.  
  278.  
  279.  
  280.                           Expires in six months         [Page 5]
  281.  
  282. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  283.  
  284.  
  285.    it very suitable for efficient internal processing in certain scenar-
  286.    ios. We therefore in particular give conversion functions between
  287.    MLSF and our proposals in the appendices.
  288.  
  289.    MLSF continues a long tradition of utilizing unused bit combinations
  290.    for internal processing speedups. Exposing such methods to the out-
  291.    side of an implementation, however, can lead to serious restrictions
  292.    and undesired biases towards certain implementations.
  293.  
  294.    The main difference between the two proposals given here is that TELT
  295.    has to exclude certain character sequences from the untagged text,
  296.    whereas STLT has a potential to use a special, newly defined, code-
  297.    point, that is guaranteed not to appear in text per se.
  298.  
  299.  
  300. Acknowledgements
  301.  
  302.    The motivation to write this document came from Harald Alvestran.
  303.    Further acknowledgements go to Lisa Moore, Mark Davis, Ken Whistler,
  304.    Glenn Adams, and others from the UTC (Unicode Technical Committee),
  305.    to Rob Pike, and to Chris Newman, Ned Freed, and Mark Crispin from
  306.    the IETF ACAP working group.
  307.  
  308.  
  309.  
  310.  
  311.  
  312. Bibliography
  313.  
  314.    [Unicode2]     The Unicode Standard, Version 2, Addison-Wesley, Read-
  315.                   ing, MA, 1996.
  316.  
  317.    [ISO-10646]    ISO/IEC 10646-1:1993. International Standard -- Infor-
  318.                   mation technology -- Universal Multiple-Octet Coded
  319.                   Character Set (UCS) -- Part 1: Architecture and Basic
  320.                   Multilingual Plane.
  321.  
  322.    [JIS1997]      Japanese Industrial Standard, "7-bit and 8-bit Double
  323.                   Byte Coded Kanji Sets for Information Interchange",
  324.                   JIS X 0208:1997.
  325.  
  326.    [MLSF]         C. Newman, "Multi-Lingual String Format (MLSF)",
  327.                   draft-ietf-acap-mlsf-01.txt, work in progress, June
  328.                   1997.
  329.  
  330.    [RFC1766]      Alvestran, H., "Tags for the Identification of Lan-
  331.                   guages", RFC 1766.
  332.  
  333.  
  334.  
  335.  
  336.                           Expires in six months         [Page 6]
  337.  
  338. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  339.  
  340.  
  341.    [RFC2070]      F. Yergeau, G. Nicol, G. Adams, and M. Duerst, "Inter-
  342.                   nationalization of the Hypertext Markup Language", RFC
  343.                   2070, January 1997.
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352. Author's Address
  353.  
  354.    Martin J. Duerst
  355.    Multimedia-Laboratory
  356.    Department of Computer Science
  357.    University of Zurich
  358.    Winterthurerstrasse 190
  359.    CH-8057 Zurich
  360.    Switzerland
  361.  
  362.    Tel: +41 1 257 43 16
  363.    Fax: +41 1 363 00 35
  364.    E-mail: mduerst@ifi.unizh.ch
  365.  
  366.  
  367.      NOTE -- Please write the author's name with u-Umlaut wherever
  368.      possible, e.g. in HTML as Dürst.
  369.  
  370.  
  371.  
  372.  
  373. Appendix A.  Conversion from TELT to MLSF
  374.  
  375.    This is sample code to convert from text/enriched-style language tag-
  376.    ing to MLSF. It is assumed that the source is in UTF-8, and that the
  377.    output buffer (outp) is long enough to hold the result. The code uses
  378.    the functions defined in [MLSF] for convenience.
  379.  
  380.  
  381.    #include <string.h>
  382.  
  383.    void TELTtoMLSF (unsigned char *outp, unsigned char *inp)
  384.    {
  385.        unsigned char tagbuff[256];
  386.        unsigned char *temp;
  387.  
  388.        while (*inp) {
  389.  
  390.  
  391.  
  392.                           Expires in six months         [Page 7]
  393.  
  394. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  395.  
  396.  
  397.            if (!strncmp(inp, "<ALTLANG>", 9)) {
  398.                inp += 9;
  399.                *outp++ = 0xFE;
  400.            }
  401.            else if (!strncmp(inp, "<LANG=", 6)) {
  402.                inp += 6;
  403.                temp= tagbuff;
  404.                while (*inp != '>')
  405.                    *temp++ = *imp++;
  406.                *temp= 0;
  407.                outp += MLSFlangencode(outp, tagbuff);
  408.            }
  409.            else
  410.                *inp++= *outp++;
  411.        }
  412.        *outp= 0;
  413.    }
  414.  
  415.  
  416.  
  417.  
  418. Appendix B.  Conversion from STLT to MLSF
  419.  
  420.    This is sample code to convert from Start Tag Character style lan-
  421.    guage taging to MLSF. It is assumed that the source is in UTF-8, and
  422.    that the output buffer (outp) is long enough to hold the result. The
  423.    code uses the functions defined in [MLSF] for convenience.
  424.  
  425.  
  426.  
  427.    void STLTtoMLSF (unsigned char *outp, unsigned char *inp)
  428.    {
  429.        unsigned char tagbuff[256];
  430.        unsigned char *temp;
  431.  
  432.        while (*inp) {
  433.            if (!strncmp(inp, "\xC2\xA7%#", 4)) {
  434.                inp += 4;
  435.                *outp++ = 0xFE;
  436.            }
  437.            else if (!strncmp(inp, "\xC2\xA7", 2)) {
  438.                inp += 2;
  439.                temp= tagbuff;
  440.                while (*inp != '&')
  441.                    *temp++ = *imp++;
  442.                *temp= 0;
  443.                outp += MLSFlangencode(outp, tagbuff);
  444.            }
  445.  
  446.  
  447.  
  448.                           Expires in six months         [Page 8]
  449.  
  450. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  451.  
  452.  
  453.            else
  454.                *inp++= *outp++;
  455.        }
  456.        *outp= 0;
  457.    }
  458.  
  459.  
  460.  
  461.  
  462. Appendix C.  Conversion from MLSF to TELT
  463.  
  464.    This is sample code to convert from MLSF to text/enriched-style lan-
  465.    guage taging. It is assumed that the output buffer (outp) is long
  466.    enough to hold the result. The code uses the functions defined in
  467.    [MLSF] for convenience.
  468.  
  469.  
  470.    void MLSFtoTELT (unsigned char *outp, unsigned char *inp)
  471.    {
  472.        unsigned char tagbuff[256];
  473.        unsigned char *temp;
  474.        int len;
  475.  
  476.        while (*inp) {
  477.         /* for speed, first insert a test (*inp != "<") */
  478.            if (*inp == 0xFE) {
  479.                inp++;
  480.                strcpy (outp, "<ALTLANG>");
  481.                outp+= 9;
  482.            }
  483.            else if (*inp >= 0xC0 && inp[1] > 0xC0) {
  484.                inp+= MLSFlangdecode(tagbuff, inp);
  485.                strcpy (outp, "<LANG=");
  486.                outp+= 6;
  487.                temp= tagbuff;
  488.                while (*temp)
  489.                    *outp++ = *temp++;
  490.                *outp++ = ">";
  491.            }
  492.            else { /* maybe just *outp++ = *inp++ is enough here? */
  493.                len = utlen[*inp];
  494.                if (len > 6) break;
  495.                while (len-- && *src)
  496.                    *outp++ = *inp++;
  497.            }
  498.        }
  499.        *outp= 0;
  500.    }
  501.  
  502.  
  503.  
  504.                           Expires in six months         [Page 9]
  505.  
  506. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  507.  
  508.  
  509. Appendix D.  Conversion from MLSF to Start Tag Character
  510.  
  511.    This is sample code to convert from MLSF to Start Tag Character style
  512.    language taging. It is assumed that the output buffer (outp) is long
  513.    enough to hold the result. The code uses the functions defined in
  514.    [MLSF] for convenience.
  515.  
  516.  
  517.    void MLSFtoSTLT (unsigned char *outp, unsigned char *inp)
  518.    {
  519.        unsigned char tagbuff[256];
  520.        unsigned char *temp;
  521.        int len;
  522.  
  523.        while (*inp) {
  524.            if (*inp == 0xFE) {
  525.                inp++;
  526.                strcpy (outp, "\xC2\xA7%#");
  527.                outp+= 9;
  528.            }
  529.            else if (*inp >= 0xC0 && inp[1] > 0xC0) {
  530.                inp+= MLSFlangdecode(tagbuff, inp);
  531.                strcpy (outp, "\xC2\xA7");
  532.                outp+= 6;
  533.                temp= tagbuff;
  534.                while (*temp)
  535.                    *outp++ = *temp++;
  536.                *outp++ = "&";
  537.            }
  538.            else { /* maybe just *outp++ = *inp++ is enough here? */
  539.                len = utlen[*inp];
  540.                if (len > 6) break;
  541.                while (len-- && *src)
  542.                    *outp++ = *inp++;
  543.            }
  544.        }
  545.        *outp= 0;
  546.    }
  547.  
  548.  
  549.  
  550.  
  551.  
  552. Appendix E.  Elimination of False Positives in TELT
  553.  
  554.    This is sample code to eliminate false positives in TELT (i.e. check-
  555.    ing whether a match found by a search routine starts inside a tag).
  556.    The elimination of false positives in STLT is structurally equivalent
  557.  
  558.  
  559.  
  560.                           Expires in six months        [Page 10]
  561.  
  562. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  563.  
  564.  
  565.    and therefore not given explicitly here.
  566.  
  567.  
  568.    int TELTfalse (unsigned char *inp, unsigned char *pos)
  569.    {
  570.        while (inp <= pos) {
  571.            if (!strncmp(inp, "<ALTLANG>", 9)) {
  572.                inp += 9;
  573.                if (inp > pos)
  574.                    return 1;
  575.            }
  576.            else (!strncmp(inp, "<LANG=", 6)) {
  577.                inp += 6;
  578.                while (*inp++ != '>')  ;
  579.                if (inp > pos)
  580.                    return 1;
  581.            }
  582.        }
  583.        return 0;
  584.    }
  585.  
  586.  
  587.  
  588. Appendix F.  Elimination of Tags from TELT
  589.  
  590.    This is sample code to eliminate tags from TELT (in UTF-8), thereby
  591.    leaving only plain text. The elimination of tags from STLT is struc-
  592.    turally equivalent and therefore not given explicitly here.
  593.  
  594.  
  595.  
  596.  
  597.    void TELTclean (unsigned char *inp, unsigned char *outp)
  598.    {
  599.        while (*inp) {
  600.            if (!strncmp(inp, "<ALTLANG>", 9))
  601.                inp += 9;
  602.            else if (!strncmp(inp, "<LANG=", 6)) {
  603.                while (*inp++ != '>')  ;
  604.            }
  605.            else
  606.                *inp++= *outp++;
  607.        }
  608.        *outp= 0;
  609.    }
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.                           Expires in six months        [Page 11]
  617.  
  618. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  619.  
  620.  
  621. Appendix G.  Selection of the "best" alternative from TELT
  622.  
  623.    This is sample code selects the "best" language match from TELT.
  624.    Assume input language tag has been converted to upper case. Assume
  625.    language tags won't exceed 256 characters.  Returns a pointer to the
  626.    start of the "best" match.  Code for STLT is structurally equivalent
  627.    and therefore not given explicitly here.
  628.  
  629.  
  630.  
  631.    unsigned char TELTselect (unsigned char *inp, unsigned char *tag)
  632.    {
  633.        unsigned char tagbuff[256];
  634.        unsigned char *match1, match2;
  635.        unsigned char best= str;
  636.        int bestlen= 0;
  637.        int start= 1;
  638.        int mlen;
  639.  
  640.        if (tag == NULL || !*tag)
  641.            return;
  642.  
  643.        while (*inp) {
  644.            if (!strncmp(inp, "<ALTLANG>", 9)) {
  645.                inp += 9;
  646.                *outp++ = 0xFE;
  647.                start= 1;
  648.            }
  649.            if (start) {
  650.                mlen= 0;
  651.                /* get tag into tagbuff */
  652.                if (!strncmp(inp, "<LANG=", 6)) {
  653.                    inp += 6;
  654.                    match1= tagbuff;
  655.                    while (*inp != '>')
  656.                        *match1++ = *imp++;
  657.                    *match1= 0;
  658.                    inp++;
  659.                }
  660.                else *tagbuff= 0;
  661.  
  662.                /* check match */
  663.                match1= tagbuff;
  664.                match2= tag;
  665.                while (*match1 && *match1++ == *match2++) {
  666.                    if (*match2=="-" && (*match2=="-" || !*match2))
  667.                        mlen = match1 - tagbuff;
  668.                }
  669.  
  670.  
  671.  
  672.                           Expires in six months        [Page 12]
  673.  
  674. Internet Draft    Alternative Language Tagings for ACAP         May 1997
  675.  
  676.  
  677.                if (!*match2 && (*match1=='-' || !*match1)) {
  678.                    best = str;
  679.                    break;
  680.                }
  681.  
  682.                if (mlen > bestlen) {
  683.                    best = str;
  684.                    bestlen = mlen;
  685.                }
  686.  
  687.                /* search next alternative */
  688.                start = 0;
  689.            }
  690.            else
  691.                inp++;
  692.        }
  693.  
  694.        return best;
  695.    }
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.                           Expires in six months        [Page 13]
  729.  
  730.