UNIVERS
15.3
UNIVERS base processing software API
Main Page
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
mix
char2ops.h
1
/* char2ops.h */
2
/* $Id: char2ops.h,v 1.1 2000/02/11 12:55:22 vlad Exp $ */
3
#ifndef __char2ops_h
4
#define __char2ops_h
5
6
/* wchar_t definition */
7
#include <stddef.h>
8
#include <stdlib.h>
/* mb & wc functions */
9
#include <string.h>
10
11
#include <mix/Types.h>
12
#include <mix/trans.h>
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
/* __cplusplus */
17
18
19
20
/***********************************************************************
21
* Two-byte character macros
22
***********************************************************************/
23
24
/* Convert two bytes to Char2 type */
25
#define to_c2(Lead,Tail) ((((Lead)&0xffU)<<8)+((Tail)&0xffU))
26
27
/* Convert Char2 type to lead and tail bytes */
28
#define c2_lead(C) (((C)>>8)&0xffU)
29
#define c2_tail(C) ((C)&0xffU)
30
31
/* Convert Char2 to wchar_t */
32
#define c2_to_wc(C) ((wchar_t)(C))
33
34
/* Convert wchar_t to Char2 */
35
#define wc_to_c2(WC) ((WC)&0xffffU)
36
37
38
/***********************************************************************
39
* Wide char, two-byte char and multibyte strings services.
40
***********************************************************************/
41
42
/* Return number of symbols in wcstr (wide char string) */
43
int
wcs_symbols (
const
wchar_t
* wcstr);
44
45
/* Return number of symbols in c2str (Char2 string) */
46
int
c2s_symbols (
const
Char2* c2str);
47
48
/* Return exact number of true symbols in mbstr (multibyte string) */
49
int
mbs_symbols (
const
char
* mbstr);
50
51
/* Return approximate number of chars needed for multibyte string
52
representation (+ EOL) */
53
#define wcs_to_mbstrlen (const wchar_t* wcstr) \
54
(1 + sizeof(wchar_t) * wcs_symbols(wcstr))
55
56
/* Return approximate number of chars needed for multibyte string
57
representation (+ EOL) */
58
#define c2s_to_mbstrlen (const Char2* c2str) \
59
(1 + sizeof(Char_2) * c2s_symbols(c2str))
60
61
62
/* Next convertion functions allocates memory by malloc() if target
63
pointer (last argument) is NULL. */
64
65
/* Convert wchar_t string to Char2* string of expected size */
66
Char2* wcs_to_c2s (
const
wchar_t
* wcstr, Char2* c2str);
67
68
/* Convert Char2* string to wchar_t string of expected size */
69
wchar_t
* c2s_to_wcs (
const
Char2* c2str,
wchar_t
* wcstr);
70
71
/* Convert multibyte string to Char2* string of expected size,
72
meaning that multibyte string is given in mbenc encoding. */
73
Char2* mbs_to_c2s (TextEncoding mbenc,
const
char
* mbstr,
74
Char2* c2str);
75
76
/* Convert multibyte string to wchar_t string of expected size,
77
meaning that multibyte string is given in mbenc encoding. */
78
wchar_t
* mbs_to_wcs (TextEncoding mbenc,
const
char
* mbstr,
79
wchar_t
* wcstr);
80
81
82
#ifdef __cplusplus
83
};
84
#endif
/* __cplusplus */
85
86
#endif
/* char2ops.h */
Generated by
1.8.5