mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Improve unicode handling
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10947 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7ac946abe5
commit
9265808796
6 changed files with 46 additions and 99 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2001-09-21 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* configure.in: Typo in iconv cached value.
|
||||||
|
* Headers/gnustep/base/NSGeometry.h: Make const values static also.
|
||||||
|
* Source/NSConnection.m: Remove obsolete BROKEN_NESTED code.
|
||||||
|
* Source/Unicode.m: Dynamically determine best Unicode encoding.
|
||||||
|
|
||||||
2001-09-21 Richard Frith-Macdonald <rfm@gnu.org>
|
2001-09-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/gnustep/base/DistributedObjects.h:
|
* Headers/gnustep/base/DistributedObjects.h:
|
||||||
|
|
|
@ -80,9 +80,9 @@ enum _NSRectEdge
|
||||||
NSMaxYEdge
|
NSMaxYEdge
|
||||||
};
|
};
|
||||||
|
|
||||||
const NSPoint NSZeroPoint; /* A zero point. */
|
static const NSPoint NSZeroPoint; /* A zero point. */
|
||||||
const NSRect NSZeroRect; /* A zero origin rectangle. */
|
static const NSRect NSZeroRect; /* A zero origin rectangle. */
|
||||||
const NSSize NSZeroSize; /* A zero size rectangle. */
|
static const NSSize NSZeroSize; /* A zero size rectangle. */
|
||||||
|
|
||||||
/**** Function Prototypes ****************************************************/
|
/**** Function Prototypes ****************************************************/
|
||||||
|
|
||||||
|
|
|
@ -1413,96 +1413,6 @@ static BOOL multi_threaded = NO;
|
||||||
RELEASE(arp);
|
RELEASE(arp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BROKEN_NESTED_FUNCTIONS
|
|
||||||
typedef struct _NSConnection_t {
|
|
||||||
@defs(NSConnection)
|
|
||||||
} NSConnection_t;
|
|
||||||
static NSConnection_t *c_self_t;
|
|
||||||
static NSPortCoder *op = nil;
|
|
||||||
static NSPortCoder *ip = nil;
|
|
||||||
static NSConnection *c_self;
|
|
||||||
static BOOL is_exception = NO;
|
|
||||||
static BOOL second_decode = NO;
|
|
||||||
static int seq_num;
|
|
||||||
|
|
||||||
void encoder (int argnum, void *datum, const char *type, int flags)
|
|
||||||
{
|
|
||||||
#define ENCODED_ARGNAME @"argument value"
|
|
||||||
switch (*type)
|
|
||||||
{
|
|
||||||
case _C_ID:
|
|
||||||
if (flags & _F_BYCOPY)
|
|
||||||
[op encodeBycopyObject: *(id*)datum];
|
|
||||||
#ifdef _F_BYREF
|
|
||||||
else if (flags & _F_BYREF)
|
|
||||||
[op encodeByrefObject: *(id*)datum];
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
[op encodeObject: *(id*)datum];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
[op encodeValueOfObjCType: type at: datum];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void decoder(int argnum, void *datum, const char *type, int flags)
|
|
||||||
{
|
|
||||||
c_self_t = (NSConnection_t *)c_self;
|
|
||||||
if (type == 0)
|
|
||||||
{
|
|
||||||
if (ip != nil)
|
|
||||||
{
|
|
||||||
[c_self _doneInRmc: ip];
|
|
||||||
/* this must be here to avoid trashing alloca'ed retframe */
|
|
||||||
ip = (id)-1;
|
|
||||||
c_self_t->_repInCount++; /* received a reply */
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/* If we didn't get the reply packet yet, get it now. */
|
|
||||||
if (ip == nil)
|
|
||||||
{
|
|
||||||
if (c_self_t->_isValid == NO)
|
|
||||||
{
|
|
||||||
[NSException raise: NSGenericException
|
|
||||||
format: @"connection waiting for request was shut down"];
|
|
||||||
}
|
|
||||||
ip = [c_self _getReplyRmc: seq_num];
|
|
||||||
/*
|
|
||||||
* Find out if the server is returning an exception instead
|
|
||||||
* of the return values.
|
|
||||||
*/
|
|
||||||
[ip decodeValueOfObjCType: @encode(BOOL) at: &is_exception];
|
|
||||||
if (is_exception == YES)
|
|
||||||
{
|
|
||||||
/* Decode the exception object, and raise it. */
|
|
||||||
id exc;
|
|
||||||
[ip decodeValueOfObjCType: @encode(id) at: &exc];
|
|
||||||
[c_self _doneInRmc: ip];
|
|
||||||
ip = (id)-1;
|
|
||||||
/* xxx Is there anything else to clean up in
|
|
||||||
dissect_method_return()? */
|
|
||||||
[exc raise];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (*type == _C_PTR)
|
|
||||||
else
|
|
||||||
[ip decodeValueOfObjCType: type+1 at: datum];
|
|
||||||
[ip decodeValueOfObjCType: type at: datum];
|
|
||||||
/* -decodeValueOfObjCType:at: malloc's new memory
|
|
||||||
for pointers. We need to make sure it gets freed eventually
|
|
||||||
so we don't have a memory leak. Request here that it be
|
|
||||||
autorelease'ed. Also autorelease created objects. */
|
|
||||||
if (second_decode == NO)
|
|
||||||
{
|
|
||||||
if ((*type == _C_CHARPTR || *type == _C_PTR) && *(void**)datum != 0)
|
|
||||||
[NSData dataWithBytesNoCopy: *(void**)datum length: 1];
|
|
||||||
}
|
|
||||||
else if (*type == _C_ID)
|
|
||||||
AUTORELEASE(*(id*)datum);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void retDecoder(DOContext *ctxt)
|
static void retDecoder(DOContext *ctxt)
|
||||||
{
|
{
|
||||||
NSPortCoder *coder = ctxt->decoder;
|
NSPortCoder *coder = ctxt->decoder;
|
||||||
|
|
|
@ -52,11 +52,15 @@ struct _ucc_ {unichar from; char to;};
|
||||||
// The rest of the GNUstep code stores UNICODE in internal byte order,
|
// The rest of the GNUstep code stores UNICODE in internal byte order,
|
||||||
// so we do the same. This should be UCS-2-INTERNAL for libiconv
|
// so we do the same. This should be UCS-2-INTERNAL for libiconv
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
#define UNICODE_ENC "UNICODEBIG"
|
#define UNICODE_INT "UNICODEBIGL"
|
||||||
#else
|
#else
|
||||||
#define UNICODE_ENC "UNICODELITTLE"
|
#define UNICODE_INT "UNICODELITTLE"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define UNICODE_ENC ((unicode_enc) ? unicode_enc : internal_unicode_enc())
|
||||||
|
|
||||||
|
static const char *unicode_enc = NULL;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,6 +178,8 @@ const struct _strenc_ str_encoding_table[]=
|
||||||
{0, "Unknown encoding"}
|
{0, "Unknown encoding"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NSStringEncoding *GetAvailableEncodings()
|
NSStringEncoding *GetAvailableEncodings()
|
||||||
{
|
{
|
||||||
// FIXME: This should check which iconv definitions are available and
|
// FIXME: This should check which iconv definitions are available and
|
||||||
|
@ -279,6 +285,30 @@ GetEncodingName(NSStringEncoding encoding)
|
||||||
|
|
||||||
#ifdef HAVE_ICONV
|
#ifdef HAVE_ICONV
|
||||||
|
|
||||||
|
/* Check to see what type of internal unicode format the library supports */
|
||||||
|
static const char *
|
||||||
|
internal_unicode_enc()
|
||||||
|
{
|
||||||
|
iconv_t conv;
|
||||||
|
unicode_enc = UNICODE_INT;
|
||||||
|
conv = iconv_open(unicode_enc, "ASCII");
|
||||||
|
if (conv != (iconv_t)-1)
|
||||||
|
{
|
||||||
|
iconv_close(conv);
|
||||||
|
return unicode_enc;
|
||||||
|
}
|
||||||
|
unicode_enc = "UCS-2-INTERNAL";
|
||||||
|
conv = iconv_open(unicode_enc, "ASCII");
|
||||||
|
if (conv != (iconv_t)-1)
|
||||||
|
{
|
||||||
|
iconv_close(conv);
|
||||||
|
return unicode_enc;
|
||||||
|
}
|
||||||
|
unicode_enc = "UCS-2";
|
||||||
|
/* This had better work */
|
||||||
|
return unicode_enc;
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
iconv_stringforencoding(NSStringEncoding enc)
|
iconv_stringforencoding(NSStringEncoding enc)
|
||||||
{
|
{
|
||||||
|
|
4
configure
vendored
4
configure
vendored
|
@ -5463,7 +5463,7 @@ else
|
||||||
echo "$ac_t""no" 1>&6
|
echo "$ac_t""no" 1>&6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x"$av_cv_lib_giconv_main" = xyes; then
|
if test x"$ac_cv_lib_giconv_main" = xyes; then
|
||||||
cat >> confdefs.h <<\EOF
|
cat >> confdefs.h <<\EOF
|
||||||
#define HAVE_ICONV 1
|
#define HAVE_ICONV 1
|
||||||
EOF
|
EOF
|
||||||
|
@ -5516,7 +5516,7 @@ else
|
||||||
echo "$ac_t""no" 1>&6
|
echo "$ac_t""no" 1>&6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x"$av_cv_lib_iconv_main" = xyes; then
|
if test x"$ac_cv_lib_iconv_main" = xyes; then
|
||||||
cat >> confdefs.h <<\EOF
|
cat >> confdefs.h <<\EOF
|
||||||
#define HAVE_ICONV 1
|
#define HAVE_ICONV 1
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -916,12 +916,12 @@ if test $ac_cv_func_iconv = no; then
|
||||||
|
|
||||||
# BSDs install this lib as libgiconv
|
# BSDs install this lib as libgiconv
|
||||||
AC_CHECK_LIB(giconv, main)
|
AC_CHECK_LIB(giconv, main)
|
||||||
if test x"$av_cv_lib_giconv_main" = xyes; then
|
if test x"$ac_cv_lib_giconv_main" = xyes; then
|
||||||
AC_DEFINE(HAVE_ICONV)
|
AC_DEFINE(HAVE_ICONV)
|
||||||
AC_DEFINE(HAVE_GICONV_H)
|
AC_DEFINE(HAVE_GICONV_H)
|
||||||
else
|
else
|
||||||
AC_CHECK_LIB(iconv, main)
|
AC_CHECK_LIB(iconv, main)
|
||||||
if test x"$av_cv_lib_iconv_main" = xyes; then
|
if test x"$ac_cv_lib_iconv_main" = xyes; then
|
||||||
AC_DEFINE(HAVE_ICONV)
|
AC_DEFINE(HAVE_ICONV)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue