2 * @file rubywstrings.swg
4 * @date Fri May 4 17:49:40 2007
6 * @brief Currently, Ruby does not support Unicode or WChar properly, so these
7 * are still treated as char arrays for now.
8 * There are other libraries available that add support to this in
9 * ruby including WString, FXString, etc.
14 /* ------------------------------------------------------------
15 * utility methods for wchar_t strings
16 * ------------------------------------------------------------ */
18 %fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
20 SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc)
22 return SWIG_AsCharPtrAndSize( obj, (char**)cptr, psize, alloc);
25 // if ( TYPE(obj) == T_STRING ) {
27 // obj = tmp = SWIG_Unicode_FromObject(obj);
32 // Py_ssize_t len = PyUnicode_GetSize(obj);
35 // *cptr = %new_array(len + 1, wchar_t);
36 // SWIG_Unicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
39 // if (psize) *psize = (size_t) len + 1;
40 // if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0;
43 // swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
44 // if (pwchar_descriptor) {
46 // if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
47 // if (cptr) *cptr = (wchar_t *)vptr;
48 // if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
53 // return SWIG_TypeError;
57 %fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
58 SWIGINTERNINLINE VALUE
59 SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
61 return SWIG_FromCharPtrAndSize( (const char*)carray, size);
63 // if (size > INT_MAX) {
64 // swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
65 // return pwchar_descriptor ?
66 // SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : Qnil;
68 // return SWIG_Unicode_FromWideChar(carray, %numeric_cast(size,int));