src/Pure/System/isabelle_charset.scala
author wenzelm
Thu, 20 Feb 2014 14:36:17 +0100
changeset 55618 995162143ef4
parent 50203 00d8ad713e32
child 71359 411c0322c09d
permissions -rw-r--r--
tuned imports;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43517
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/System/isabelle_charset.scala
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
     3
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
     4
Charset for Isabelle symbols.
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
     5
*/
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
     6
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
     7
package isabelle
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
     8
55618
995162143ef4 tuned imports;
wenzelm
parents: 50203
diff changeset
     9
43517
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    10
import java.nio.Buffer
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    11
import java.nio.{ByteBuffer, CharBuffer}
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    12
import java.nio.charset.{Charset, CharsetDecoder, CharsetEncoder, CoderResult}
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    13
import java.nio.charset.spi.CharsetProvider
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    14
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    15
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    16
object Isabelle_Charset
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    17
{
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    18
  val name: String = "UTF-8-Isabelle-test"  // FIXME
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    19
  lazy val charset: Charset = new Isabelle_Charset
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    20
}
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    21
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    22
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    23
class Isabelle_Charset extends Charset(Isabelle_Charset.name, null)
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    24
{
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    25
  override def contains(cs: Charset): Boolean =
50203
00d8ad713e32 explicit module UTF8;
wenzelm
parents: 44778
diff changeset
    26
    cs.name.equalsIgnoreCase(UTF8.charset_name) || UTF8.charset.contains(cs)
43517
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    27
50203
00d8ad713e32 explicit module UTF8;
wenzelm
parents: 44778
diff changeset
    28
  override def newDecoder(): CharsetDecoder = UTF8.charset.newDecoder
43517
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    29
50203
00d8ad713e32 explicit module UTF8;
wenzelm
parents: 44778
diff changeset
    30
  override def newEncoder(): CharsetEncoder = UTF8.charset.newEncoder
43517
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    31
}
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    32
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    33
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    34
class Isabelle_Charset_Provider extends CharsetProvider
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    35
{
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    36
  override def charsetForName(name: String): Charset =
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    37
  {
44778
18b1ba7cfcfe deactivate unfinished charset provider for now, to avoid user confusion;
wenzelm
parents: 43517
diff changeset
    38
    // FIXME inactive
18b1ba7cfcfe deactivate unfinished charset provider for now, to avoid user confusion;
wenzelm
parents: 43517
diff changeset
    39
    // if (name.equalsIgnoreCase(Isabelle_Charset.name)) Isabelle_Charset.charset
18b1ba7cfcfe deactivate unfinished charset provider for now, to avoid user confusion;
wenzelm
parents: 43517
diff changeset
    40
    // else null
18b1ba7cfcfe deactivate unfinished charset provider for now, to avoid user confusion;
wenzelm
parents: 43517
diff changeset
    41
    null
43517
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    42
  }
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    43
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    44
  override def charsets(): java.util.Iterator[Charset] =
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    45
  {
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    46
    import scala.collection.JavaConversions._
44778
18b1ba7cfcfe deactivate unfinished charset provider for now, to avoid user confusion;
wenzelm
parents: 43517
diff changeset
    47
    // FIXME inactive
18b1ba7cfcfe deactivate unfinished charset provider for now, to avoid user confusion;
wenzelm
parents: 43517
diff changeset
    48
    // Iterator(Isabelle_Charset.charset)
18b1ba7cfcfe deactivate unfinished charset provider for now, to avoid user confusion;
wenzelm
parents: 43517
diff changeset
    49
    Iterator()
43517
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    50
  }
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    51
}
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents:
diff changeset
    52