ReactOS 0.4.16-dev-306-g647d351
fold.c File Reference
#include "wine/unicode.h"
Include dependency graph for fold.c:

Go to the source code of this file.

Functions

static WCHAR to_unicode_digit (WCHAR ch)
 
static WCHAR to_unicode_native (WCHAR ch)
 
static int get_ligature_len (WCHAR wc)
 
static const WCHARget_ligature (WCHAR wc)
 
int wine_fold_string (int flags, const WCHAR *src, int srclen, WCHAR *dst, int dstlen)
 

Variables

static const WCHAR wine_ligatures []
 
static const WCHAR wine_expanded_ligatures [][4]
 

Function Documentation

◆ get_ligature()

static const WCHAR * get_ligature ( WCHAR  wc)
inlinestatic

Definition at line 100 of file fold.c.

101{
102 static const WCHAR empty_ligature[] = { '\0','\0','\0', 0 };
103 int low = 0, high = sizeof(wine_ligatures)/sizeof(WCHAR) -1;
104 while (low <= high)
105 {
106 int pos = (low + high) / 2;
107 if (wine_ligatures[pos] < wc)
108 low = pos + 1;
109 else if (wine_ligatures[pos] > wc)
110 high = pos - 1;
111 else
113 }
114 return empty_ligature;
115}
static const WCHAR wine_expanded_ligatures[][4]
Definition: fold.c:45
static const WCHAR wine_ligatures[]
Definition: fold.c:35
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ get_ligature_len()

static int get_ligature_len ( WCHAR  wc)
inlinestatic

Definition at line 84 of file fold.c.

85{
86 int low = 0, high = sizeof(wine_ligatures)/sizeof(WCHAR) -1;
87 while (low <= high)
88 {
89 int pos = (low + high) / 2;
90 if (wine_ligatures[pos] < wc)
91 low = pos + 1;
92 else if (wine_ligatures[pos] > wc)
93 high = pos - 1;
94 else
96 }
97 return 0;
98}

◆ to_unicode_digit()

static WCHAR to_unicode_digit ( WCHAR  ch)
inlinestatic

Definition at line 23 of file fold.c.

24{
25 extern const WCHAR wine_digitmap[] DECLSPEC_HIDDEN;
26 return ch + wine_digitmap[wine_digitmap[ch >> 8] + (ch & 0xff)];
27}
const WCHAR DECLSPEC_HIDDEN wine_digitmap[5933]
Definition: digitmap.c:7
#define DECLSPEC_HIDDEN
Definition: precomp.h:8

◆ to_unicode_native()

static WCHAR to_unicode_native ( WCHAR  ch)
inlinestatic

Definition at line 29 of file fold.c.

30{
32 return ch + wine_compatmap[wine_compatmap[ch >> 8] + (ch & 0xff)];
33}
const WCHAR DECLSPEC_HIDDEN wine_compatmap[1497]
Definition: digitmap.c:789

◆ wine_fold_string()

int wine_fold_string ( int  flags,
const WCHAR src,
int  srclen,
WCHAR dst,
int  dstlen 
)

Definition at line 118 of file fold.c.

119{
120 WCHAR *dstbase = dst;
121 const WCHAR *expand;
122 int i;
123
124 if (srclen == -1)
125 srclen = strlenW(src) + 1; /* Include terminating NUL in count */
126
127 if (!dstlen)
128 {
129 /* Calculate the required size for dst */
130 dstlen = srclen;
131
132 if (flags & MAP_EXPAND_LIGATURES)
133 {
134 while (srclen--)
135 {
137 src++;
138 }
139 }
140 else if (flags & MAP_COMPOSITE)
141 {
142 /* FIXME */
143 }
144 else if (flags & MAP_PRECOMPOSED)
145 {
146 /* FIXME */
147 }
148 return dstlen;
149 }
150
151 if (srclen > dstlen)
152 return 0;
153
154 dstlen -= srclen;
155
156 /* Actually perform the mapping(s) specified */
157 for (i = 0; i < srclen; i++)
158 {
159 WCHAR ch = *src;
160
161 if (flags & MAP_EXPAND_LIGATURES)
162 {
163 expand = get_ligature(ch);
164 if (expand[0])
165 {
166 if (!dstlen--)
167 return 0;
168 dst[0] = expand[0];
169 if (expand[2])
170 {
171 if (!dstlen--)
172 return 0;
173 *++dst = expand[1];
174 ch = expand[2];
175 }
176 else
177 ch = expand[1];
178 dst++;
179 }
180 }
181 else if (flags & MAP_COMPOSITE)
182 {
183 /* FIXME */
184 }
185 else if (flags & MAP_PRECOMPOSED)
186 {
187 /* FIXME */
188 }
189 if (flags & MAP_FOLDDIGITS)
190 ch = to_unicode_digit(ch);
191 if (flags & MAP_FOLDCZONE)
192 ch = to_unicode_native(ch);
193
194 *dst++ = ch;
195 src++;
196 }
197 return dst - dstbase;
198}
static BOOL expand(LPINT ac, LPTSTR **arg, LPCTSTR pattern)
Definition: misc.c:228
static WCHAR to_unicode_digit(WCHAR ch)
Definition: fold.c:23
static WCHAR to_unicode_native(WCHAR ch)
Definition: fold.c:29
static const WCHAR * get_ligature(WCHAR wc)
Definition: fold.c:100
static int get_ligature_len(WCHAR wc)
Definition: fold.c:84
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:52
static DWORD dstlen
Definition: directory.c:51
#define strlenW(s)
Definition: unicode.h:34
#define MAP_FOLDDIGITS
Definition: winnls.h:216
#define MAP_PRECOMPOSED
Definition: winnls.h:217
#define MAP_COMPOSITE
Definition: winnls.h:218
#define MAP_FOLDCZONE
Definition: winnls.h:215

Referenced by FoldStringW().

Variable Documentation

◆ wine_expanded_ligatures

const WCHAR wine_expanded_ligatures[][4]
static

Definition at line 45 of file fold.c.

◆ wine_ligatures

const WCHAR wine_ligatures[]
static
Initial value:
=
{
0x00c6, 0x00de, 0x00df, 0x00e6, 0x00fe, 0x0132, 0x0133, 0x0152,
0x0153, 0x01c4, 0x01c5, 0x01c6, 0x01c7, 0x01c8, 0x01c9, 0x01ca,
0x01cb, 0x01cc, 0x01e2, 0x01e3, 0x01f1, 0x01f2, 0x01f3, 0x01fc,
0x01fd, 0x05f0, 0x05f1, 0x05f2, 0xfb00, 0xfb01, 0xfb02, 0xfb03,
0xfb04, 0xfb05, 0xfb06
}

Definition at line 35 of file fold.c.