longchar.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef _longchar_h_
  2. #define _longchar_h_
  3. /* longchar.h
  4. *
  5. * Copyright (C) 1992-2008,2011,2015-2018 Paul Boersma
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. * See the GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "../melder/melder.h"
  21. /********** NON-ASCII CHARACTERS **********/
  22. /* System-independent representation of some non-ASCII symbols.
  23. These symbols are represented by a backslash (\) plus two ASCII symbols.
  24. In 1992, we needed this because Praat is multilingual.
  25. Nowadays, we have Unicode, which is a system-independent representation as well.
  26. Still, backslash sequences are useful if your computer does not have a fast input method for the symbols
  27. you want to use, which is likely to happen with phonetic characters.
  28. - For the characters of the following languages, we supply backslash sequences as well as size and PostScript information:
  29. English, Dutch, German, French, Spanish, Portuguese, Italian,
  30. Danish, Swedish, Norwegian, Welsh, Luxemburgian, Frisian.
  31. - For the characters of the following languages, we supply backslash sequences (PostScript will not work yet):
  32. Hungarian, Polish, Czech, Rumanian, Icelandic, Serbocroat, Turkish, Greek, Hebrew.
  33. - By supporting Unicode, we also support other alphabets, such as Arabic, Chinese, Cyrillic, and Devanagari;
  34. since we have no backslash support for these, you need a specialized input method to enter them into Praat.
  35. */
  36. /* Alphabets. */
  37. #define Longchar_ROMAN 0
  38. #define Longchar_SYMBOL 1
  39. #define Longchar_PHONETIC 2
  40. #define Longchar_DINGBATS 3
  41. #define Longchar_RIGHT_TO_LEFT 4
  42. /********** Conversion of Roman native and generic string encodings. **********/
  43. char32_t * Longchar_nativize32 (const char32_t *generic, char32_t *native, int educateQuotes);
  44. char32_t *Longchar_genericize32 (const char32_t *native, char32_t *generic);
  45. /*
  46. Function:
  47. Copies the string 'native' to the string 'generic',
  48. interpreting non-ASCII native characters as belonging to the Roman alphabet.
  49. Returns 'generic' as a convenience.
  50. 'generic' can become at most three times as long as 'native'.
  51. Usage:
  52. translating user input into a generic string.
  53. */
  54. typedef struct structLongchar_Info {
  55. unsigned char first, second; /* First and second character of two-byte encoding. */
  56. /* For ASCII characters, 'second' is a space. */
  57. unsigned char alphabet; /* Roman, Symbol, Phonetic, or Dingbats. */
  58. unsigned char isDiacritic;
  59. struct {
  60. const char *name; /* The PostScript name, starting with a slash. */
  61. /* The widths in thousands of the height. */
  62. short times, timesBold, timesItalic, timesBoldItalic; /* Times. */
  63. short helvetica, helveticaBold; /* Helvetica. */
  64. short palatino, palatinoBold, palatinoItalic, palatinoBoldItalic; /* Palatino. */
  65. /* Courier width always 600. */
  66. }
  67. ps; /* PostScript properties. */
  68. unsigned short xwinEncoding; /* The one-byte encoding for X11 (ISO8859-1 for Roman). */
  69. unsigned short winEncoding; /* The one-byte encoding for Windows (ISO8859-1 for Roman; SILDoulosIPA 1993). */
  70. unsigned short macEncoding; /* The one-byte encoding for Macintosh (Mac for Roman; SILDoulosIPA 1993). */
  71. unsigned short psEncoding; /* The one-byte encoding for PostScript (Mac-Praat, TeX-xipa-Praat). */
  72. char32 unicode; /* The four-byte encoding for Unicode. */
  73. }
  74. *Longchar_Info;
  75. Longchar_Info Longchar_getInfo (char32_t kar1, char32_t kar2);
  76. Longchar_Info Longchar_getInfoFromNative (char32_t kar);
  77. /* If no info found, these two routines return the info for a space. */
  78. /*
  79. How should we represent the dumb ASCII double quote (")?
  80. The dumb quote is converted to a left or right double quote,
  81. on Macintosh, PostScript, and Windows
  82. (ISO8859-1 has no left and right double quotes).
  83. You can enforce the way your double quotes look by
  84. using one of these generic symbols:
  85. - \"l for a left double quote
  86. - \"r for a right double quote
  87. - \"" for a straight double quote
  88. There is no translation for single quotes, because some languages
  89. use the right single quote as an apostrophe in unpredictable positions.
  90. You can get a left single quote by typing "`",
  91. which looks like a grave accent on Macintosh;
  92. you will get a right single quote or apostrophe by typing a "'",
  93. which looks like a straight quote on Macintosh.
  94. Thus, the string typed as "`hallo'" will give you left and right quotes,
  95. even on Macintosh. (Reading this note in Xwindows may feel somewhat funny.)
  96. */
  97. inline static bool Longchar_Info_isDiacritic (Longchar_Info me) {
  98. return me -> isDiacritic;
  99. }
  100. void Longchar_init ();
  101. /* End of file longchar.h */
  102. #endif