summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2004-06-02 16:49:17 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2004-06-02 16:49:17 (GMT)
commit974ed7cfa50b666c9ab91f7a3f8f26049d387107 (patch)
treed821c74c26231d988f34764d0fdfe3494036ee95 /Include
parentb6568b91fdf7de1377dba395c6725a7307b818ee (diff)
downloadcpython-974ed7cfa50b666c9ab91f7a3f8f26049d387107.zip
cpython-974ed7cfa50b666c9ab91f7a3f8f26049d387107.tar.gz
cpython-974ed7cfa50b666c9ab91f7a3f8f26049d387107.tar.bz2
- SF #962502: Add two more methods for unicode type; width() and
iswide() for east asian width manipulation. (Inspired by David Goodger, Reviewed by Martin v. Loewis) - Move _PyUnicode_TypeRecord.flags to the end of the struct so that no padding is added for UCS-4 builds. (Suggested by Martin v. Loewis)
Diffstat (limited to 'Include')
-rw-r--r--Include/unicodeobject.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 1690f8a..345dacf 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -180,6 +180,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
# define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding
# define PyUnicode_GetMax PyUnicodeUCS2_GetMax
# define PyUnicode_GetSize PyUnicodeUCS2_GetSize
+# define PyUnicode_GetWidth PyUnicodeUCS2_GetWidth
# define PyUnicode_Join PyUnicodeUCS2_Join
# define PyUnicode_Replace PyUnicodeUCS2_Replace
# define PyUnicode_Resize PyUnicodeUCS2_Resize
@@ -199,6 +200,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
# define _PyUnicode_IsLinebreak _PyUnicodeUCS2_IsLinebreak
# define _PyUnicode_IsLowercase _PyUnicodeUCS2_IsLowercase
# define _PyUnicode_IsNumeric _PyUnicodeUCS2_IsNumeric
+# define _PyUnicode_IsWide _PyUnicodeUCS2_IsWide
# define _PyUnicode_IsTitlecase _PyUnicodeUCS2_IsTitlecase
# define _PyUnicode_IsUppercase _PyUnicodeUCS2_IsUppercase
# define _PyUnicode_IsWhitespace _PyUnicodeUCS2_IsWhitespace
@@ -252,6 +254,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
# define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding
# define PyUnicode_GetMax PyUnicodeUCS4_GetMax
# define PyUnicode_GetSize PyUnicodeUCS4_GetSize
+# define PyUnicode_GetWidth PyUnicodeUCS4_GetWidth
# define PyUnicode_Join PyUnicodeUCS4_Join
# define PyUnicode_Replace PyUnicodeUCS4_Replace
# define PyUnicode_Resize PyUnicodeUCS4_Resize
@@ -270,6 +273,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
# define _PyUnicode_IsLinebreak _PyUnicodeUCS4_IsLinebreak
# define _PyUnicode_IsLowercase _PyUnicodeUCS4_IsLowercase
# define _PyUnicode_IsNumeric _PyUnicodeUCS4_IsNumeric
+# define _PyUnicode_IsWide _PyUnicodeUCS4_IsWide
# define _PyUnicode_IsTitlecase _PyUnicodeUCS4_IsTitlecase
# define _PyUnicode_IsUppercase _PyUnicodeUCS4_IsUppercase
# define _PyUnicode_IsWhitespace _PyUnicodeUCS4_IsWhitespace
@@ -315,6 +319,8 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
#define Py_UNICODE_ISALPHA(ch) iswalpha(ch)
+#define Py_UNICODE_ISWIDE(ch) _PyUnicode_IsWide(ch)
+
#else
#define Py_UNICODE_ISSPACE(ch) _PyUnicode_IsWhitespace(ch)
@@ -338,6 +344,8 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
#define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch)
+#define Py_UNICODE_ISWIDE(ch) _PyUnicode_IsWide(ch)
+
#endif
#define Py_UNICODE_ISALNUM(ch) \
@@ -430,6 +438,12 @@ PyAPI_FUNC(int) PyUnicode_GetSize(
PyObject *unicode /* Unicode object */
);
+/* Get the fixed-width representation length of the Unicode object */
+
+PyAPI_FUNC(int) PyUnicode_GetWidth(
+ PyObject *unicode /* Unicode object */
+ );
+
/* Get the maximum ordinal for a Unicode character. */
PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void);
@@ -1151,6 +1165,10 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
Py_UNICODE ch /* Unicode character */
);
+PyAPI_FUNC(int) _PyUnicode_IsWide(
+ Py_UNICODE ch /* Unicode character */
+ );
+
#ifdef __cplusplus
}
#endif