File: charactr.cc

package info (click to toggle)
wp2latex 3.97%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,228 kB
  • sloc: cpp: 45,091; ansic: 8,998; asm: 2,435; makefile: 529; sh: 19
file content (140 lines) | stat: -rw-r--r-- 3,165 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/********************************************************************************
 * program:     wp2latex                                                        *
 * function:    convert WordPerfect 1.x,2.x,3.x,4.x,5.x and 6.x files into LaTeX*
 * modul:       charactr.cc                                                     *
 * description: This modul contains descriptions of all extended characters     *
 *              and perform a conversion to their LaTeX ekvivalents.            *
 *                Currently there is a WP5.x character set and other charsets   *
 *              are converted into it.					        *
 * licency:     GPL		                                                *
 ********************************************************************************/
#include<stdio.h>
#include<stdlib.h>

#include<string.h>
#include<lists.h>
#include<sets.h>

#include "wp2latex.h"
#include "cp_lib/cptran.h"


CpTranslator *Convert2Target = NULL;

int UseGrStyle(const char ReqFlag)
{
  if((InputPS|1) == ReqFlag)
  {
    InputPS |= 1;
    return 1;
  }
  return 0;
}

#define UseStyle(Flag, LaTeX_str)  \
  if(Flag>=false) {Flag=true;return(LaTeX_str);}
  
#define Use2Styles(Flag1, LaTeX_str1, Flag2, LaTeX_str2)\
  if(Flag1>=true || (Flag1>=false && Flag2<=false))  \
		   {Flag1=true;return(LaTeX_str1);}  \
  if(Flag2>=false) {Flag2=true;return(LaTeX_str2);}

#define SWITCH_CYR(LaTeX_str) if(Cyrillic>=0) \
  { \
  cq->RequiredFont = FONT_CYRILLIC; /*Cyrillic font*/ \
  return LaTeX_str; \
  }

#define SWITCH_HEB if(cjHebrew>=0) \
  { \
  cq->RequiredFont=FONT_HEBREW;	  /*Hebrew font*/ \
  }


/** Get character froom User Character Set */
WORD UserCharSet(unsigned char char_code, TconvertedPass1 *cq)
{
  if(UserWPCharSet==NULL)
	{
	if(cq->err)
	  {         
	  cq->perc.Hide();
	  fprintf(cq->err, _("\nWarning: Please define /CurrentFontSet for user symbol %u!"), (unsigned)char_code);
	  }
	UnknownCharacters++;
	return 0xFFFF;
	}
  return (*UserWPCharSet)[char_code];
}


static char buffer[4];

const char *ExpandPlainChar(WORD wchar)
{
  buffer[0] = wchar;
  buffer[1] = 0;
  return buffer;
}


/** Return unicode character packed in ASCII. */
const char *ExpandUTF8(WORD wchar)
{
  if(wchar<=0x7F)
  {
    buffer[0] = wchar;
    buffer[1] = 0;
    return buffer;
  }

  if(wchar<=0x7FF)
  {
    buffer[0] = 0xC0 | (wchar>>6);
    buffer[1] = 0x80 | (wchar & 0x3F);
    buffer[2] = 0;
    return buffer;
  }

  buffer[0] = 0xC8 | (wchar>>12);
  buffer[1] = 0x80 | ((wchar>>6) & 0x3F);
  buffer[2] = 0x80 | (wchar & 0x3F);
  buffer[3] = 0;
  return buffer;

//static char buffer[17];
// sprintf(buffer,"\\unichar{\"%4.4X\"}", wchar);
// sprintf(buffer,"\\symbol{\"%4.4X}", wchar);
// return buffer;
}


/*This function expands an extended WP character into LaTEX sequence*/
#include "cp_lib/charactr.cc_"


#ifdef _1
unsigned short OutCodePage, WPcharset;
bool Cyrillic;
signed char Verbosing;
bool TexChars;


int main(void)
{
int i;
TconvertedPass1 cq;

Table_Init(lat);
for(i=0;i<255;i++)
	{
        printf("%d %d: %s\n\r",i,1,Ext_chr_str(1,i,&cq));
        }
printf("\n\r");

return(0);
}
#endif  /**/


/* End of charactr.cc. */