-3

I have a need to make available to the user the ability to input a small set of special characters everywhere where textual entry is permitted. The names of the characters are:

  1. FORALL.................................THERE EXISTS
  2. NOT EXISTS...........................CAPITAL PI
  3. CAPITAL SIGMA......................SUBSET OF
  4. PROPER SUBSET OF.............SUPERSET OF
  5. PROPER SUPERSET OF.........IMPLIES
  6. EQUIVALENCE.........................NOT
  7. AND..........................................OR

EDIT

As requested in two comments I am clarifying my requirement.

I want these characters to be available for user input in object editors and as output - as symbols - in object readers. Typically, these readers will show a description or a definition of the object, and the symbols will form part of that description/definition. The user will be inputting them as part of the task of describing or defining the object. The readers could be in a variety of media - web pages, custom object readers, textual documents for on or off screen reading.

I want to provide these facilities in my application, irrespective of the machine the user has. In particular I wish to provide them irrespective of:

  1. Platform
  2. The fonts available on a specific machine
  3. The locale - both keyboard and OS settings.

@Raedwald's edited answer provides a complete answer to both parts of my requirement. I am likely to accept his answer to my question. The part of his answer that I am going to need to investigate further is "2. Detect the output encoding that the output device uses. Include in this detection a check of which fonts are present." I do not know what is involved in this task.

END EDIT

4

1 回答 1

3

"Independent of the fonts", "Independent of the locale". I guess that means you want to restrict yourself to only the ASCII character set. In that case, I suggest using an escape character, in the manner of C/C++ strings. For example, if the escape character is '?', you might encode the special symbols like this:

  • ?A FORALL
  • ?E THERE EXISTS
  • ?N NOT EXISTS
  • ?P CAPITAL PI
  • ?S CAPITAL SIGMA
  • ?< SUBSET OF

And so on. Unless you want to be like W V Quine*, you should also define ?? to mean "?".


Edit: As asked for in a comment:

That deals with the input side. If you actually want to display the special symbols as special symbols, you will have to output in Unicode. You will therefore have to convert from this representation to Unicode on performing the output, or do the conversion on input and record the strings in Unicode.


Edit: As asked for in a comment:

I don't necessarily want to restrict myself to the ASCII character set. I do want the characters to be input and displayed even if the computer concerned does not have (for instance) the symbol font

  1. Store your strings in a Unicode encodings.
  2. Detect the output encoding that the output device uses. Include in this detection a check of which fonts are present.
  3. If the output encoding can support output of all the required special characters, have your output code convert from Unicode to the encoding that the output device uses. Otherwise have your output code write the special characters using the same escape sequences as you used for input.

* The philosopher W V Quine famously altered his mechanical typewriter, replacing some of the type with logical symbols, including the question mark. When asked "You don't miss the question mark?", he replied "Well, you see, I deal in certainties.".

于 2012-08-25T15:55:02.717 回答