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