The R Project SVN R

Rev

Rev 70788 | Rev 79676 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 70788 Rev 72707
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 2005-2016   The R Core Team
3
 *  Copyright (C) 2005-2017   The R Core Team
4
 *
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
8
 *  (at your option) any later version.
Line 37... Line 37...
37
#include <wchar.h>
37
#include <wchar.h>
38
#include <ctype.h>
38
#include <ctype.h>
39
#include <wctype.h>
39
#include <wctype.h>
40
 
40
 
41
/*
41
/*
-
 
42
 * The Rwchar_t typedef represents a single Unicode code point.  On most systems it's the same
-
 
43
 * as wchar_t, but on Windows (and others?) where wchar_t is too small and UTF-16 is used,
-
 
44
 * it is an unsigned int instead.
-
 
45
 */
-
 
46
 
-
 
47
#ifdef Win32
-
 
48
typedef unsigned int Rwchar_t;
-
 
49
#else
-
 
50
typedef wchar_t Rwchar_t;
-
 
51
#endif 
-
 
52
 
-
 
53
/*
42
 * Windows CJK
54
 * Windows CJK
43
 * In Unicode, there is not a rule about character width. 
55
 * In Unicode, there is not a rule about character width. 
44
 * A letter of breadth is used in a CJK (China, Japan, Korea,
56
 * A letter of breadth is used in a CJK (China, Japan, Korea,
45
 * Taiwan, Hong Kong, and Singapore) area, and there are a
57
 * Taiwan, Hong Kong, and Singapore) area, and there are a
46
 * letter and a standard (character width is not still prescribed)
58
 * letter and a standard (character width is not still prescribed)
Line 64... Line 76...
64
 *
76
 *
65
 * The differences are mainly (but not exclusively) in the
77
 * The differences are mainly (but not exclusively) in the
66
 * Unicode 'East Asian Ambiguous' class.
78
 * Unicode 'East Asian Ambiguous' class.
67
 *
79
 *
68
 */
80
 */
-
 
81
 
69
extern int Ri18n_wcwidth(wchar_t);
82
extern int Ri18n_wcwidth(Rwchar_t);
70
extern int Ri18n_wcswidth (const wchar_t *, size_t);
83
extern int Ri18n_wcswidth (const wchar_t *, size_t);
71
 
84
 
72
/* macOS CJK and WindowXP(Japanese)
85
/* macOS CJK and WindowXP(Japanese)
73
 * iswctypes of macOS calls isctypes. no i18n.
86
 * iswctypes of macOS calls isctypes. no i18n.
74
 * For example, iswprint of Windows does not accept a macron of
87
 * For example, iswprint of Windows does not accept a macron of
Line 112... Line 125...
112
#define iswalnum(__x)     Ri18n_iswctype(__x, Ri18n_wctype("alnum"))
125
#define iswalnum(__x)     Ri18n_iswctype(__x, Ri18n_wctype("alnum"))
113
#define wctype(__x)       Ri18n_wctype(__x)
126
#define wctype(__x)       Ri18n_wctype(__x)
114
#define iswctype(__x,__y) Ri18n_iswctype(__x,__y)
127
#define iswctype(__x,__y) Ri18n_iswctype(__x,__y)
115
#endif
128
#endif
116
 
129
 
-
 
130
/* These definitions are from winnls.h in Mingw_w64.  We don't need the rest of that file. */
-
 
131
 
-
 
132
#define HIGH_SURROGATE_START 0xd800
-
 
133
#define HIGH_SURROGATE_END 0xdbff
-
 
134
#define LOW_SURROGATE_START 0xdc00
-
 
135
#define LOW_SURROGATE_END 0xdfff
-
 
136
 
-
 
137
/* The first two of these definitions use the argument twice which is bad, but we include them here in
-
 
138
 * the original form for consistency with Mingw_w64.  Users should be careful that evaluating
-
 
139
 * the argument doesn't result in side effects.
-
 
140
 */
-
 
141
 
-
 
142
#define IS_HIGH_SURROGATE(wch) (((wch) >= HIGH_SURROGATE_START) && ((wch) <= HIGH_SURROGATE_END))
-
 
143
#define IS_LOW_SURROGATE(wch) (((wch) >= LOW_SURROGATE_START) && ((wch) <= LOW_SURROGATE_END))
-
 
144
#define IS_SURROGATE_PAIR(hs, ls) (IS_HIGH_SURROGATE (hs) && IS_LOW_SURROGATE (ls))
-
 
145
 
-
 
146
# define utf8toucs32		Rf_utf8toucs32
-
 
147
Rwchar_t utf8toucs32(wchar_t high, const char *s);
-
 
148
 
117
#endif /* R_LOCALE_H */
149
#endif /* R_LOCALE_H */