rpms/openobex/devel openobex-1.3-utf.patch, NONE, 1.1 openobex.spec, 1.29, 1.30
Jiří Moskovčák (jmoskovc)
fedora-extras-commits at redhat.com
Thu Jun 5 15:47:54 UTC 2008
Author: jmoskovc
Update of /cvs/extras/rpms/openobex/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22448
Modified Files:
openobex.spec
Added Files:
openobex-1.3-utf.patch
Log Message:
Improved utf support. rhbz#430128
openobex-1.3-utf.patch:
--- NEW FILE openobex-1.3-utf.patch ---
--- openobex-1.3/lib/obex.c 2008-06-02 15:53:56.000000000 +0200
+++ openobex-1.3/lib/obex.c.utf 2008-06-02 15:54:37.000000000 +0200
@@ -65,6 +65,9 @@
typedef char *bdaddr_t;
#endif
+#include <iconv.h>
+#include <locale.h>
+
void OBEX_FreeInterfaces(obex_t *self);
/**
@@ -828,21 +831,9 @@
return 0;
}
-/**
- * OBEX_CharToUnicode - Simple char to unicode function.
- * @uc: Destination (unicode)
- * @c: Source (char)
- * @size: Length of destination buffer, at least twice the size of source
- *
- * Buffers may not overlap. Returns -1 on error.
- */
-int OBEX_CharToUnicode(uint8_t *uc, const uint8_t *c, int size)
+static int obex_ascii_to_unicode(uint8_t *uc, const uint8_t *c, int size)
{
int len, n;
- DEBUG(4, "\n");
-
- obex_return_val_if_fail(uc != NULL, -1);
- obex_return_val_if_fail(c != NULL, -1);
len = n = strlen((char *) c);
obex_return_val_if_fail(n*2+2 <= size, -1);
@@ -858,6 +849,67 @@
return (len*2)+2 ;
}
+static int obex_char_to_unicode(const char * iconv_encoding, uint8_t *uc, const uint8_t *c, int size)
+{
+ iconv_t hConv;
+ int len = -1;
+
+ if ((iconv_t)-1 != (hConv = iconv_open("UCS-2BE", iconv_encoding))) {
+ char * inBuffer = (char *)c;
+ char * outBuffer = (char *)uc;
+ size_t inBytes = strlen(inBuffer);
+ size_t outBytes = size;
+
+ if ((size_t)-1 != iconv(hConv, &inBuffer, &inBytes, &outBuffer, &outBytes)) {
+ len = size - outBytes;
+ uc[len] = 0;
+ uc[len + 1] = 0;
+ len += 2;
+ }
+
+ iconv_close(hConv);
+ }
+ return len;
+}
+
+/**
+ * OBEX_CharToUnicode - Simple char to unicode function.
+ * @uc: Destination (unicode)
+ * @c: Source (char)
+ * @size: Length of destination buffer, at least twice the size of source
+ *
+ * Buffers may not overlap. Returns -1 on error.
+ */
+int OBEX_CharToUnicode(uint8_t *uc, const uint8_t *c, int size)
+{
+ DEBUG(4, "\n");
+ int len;
+ //@@@@@
+ char const *locale = NULL;
+ obex_return_val_if_fail(uc != NULL, -1);
+ obex_return_val_if_fail(c != NULL, -1);
+
+ /* get current locale */
+ locale = setlocale(LC_CTYPE, "");
+ obex_return_val_if_fail(locale != NULL, -1);
+
+ if (strcmp(locale, "ASCII") == 0 ||
+ strcmp(locale, "C") == 0 ||
+ strcmp(locale, "POSIX") == 0 ||
+ strcmp(locale, "US-ASCII") == 0)
+ locale = "en_US.US-ASCII";
+
+ locale = strchr(locale, '.');
+ obex_return_val_if_fail(locale != NULL, -1);
+
+ locale ++;
+ obex_return_val_if_fail(locale[0] != '\0', -1);
+
+ if ((len = obex_char_to_unicode("UTF-8", uc, c, size)) >= 0) return len;
+ if ((len = obex_char_to_unicode("KOI8-U", uc, c, size)) >= 0) return len;
+ return obex_ascii_to_unicode(uc, c, size);
+}
+
/**
* OBEX_ResponseToString - Return a human understandable string from a response-code.
* @rsp: Response code.
Index: openobex.spec
===================================================================
RCS file: /cvs/extras/rpms/openobex/devel/openobex.spec,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- openobex.spec 19 Feb 2008 06:32:34 -0000 1.29
+++ openobex.spec 5 Jun 2008 15:47:11 -0000 1.30
@@ -1,7 +1,7 @@
Summary: Library for using OBEX
Name: openobex
Version: 1.3
-Release: 11%{?dist}
+Release: 12%{?dist}
License: GPLv2+
Group: System Environment/Libraries
URL: http://openobex.sourceforge.net
@@ -10,6 +10,7 @@
Patch1: openobex-1.3-push.patch
Patch2: openobex-1.3-autoconf.patch
Patch3: openobex-1.3-ipv6.patch
+Patch4: openobex-1.3-utf.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: autoconf >= 2.57, bluez-libs-devel, sed, libusb-devel
@@ -45,6 +46,7 @@
%patch1 -p1 -b .push
%patch2 -p1 -b .ipv6
%patch3 -p1 -b .autoconf
+%patch4 -p1 -b .utf
autoreconf --install --force
%build
@@ -89,6 +91,10 @@
%changelog
+* Mon Jun 2 2008 Jiri Moskovcak <jmoskovc at redhat.com> - 1.3-12
+- improved utf(non ascii) support
+- Resolves: #430128
+
* Tue Feb 19 2008 Fedora Release Engineering <rel-eng at fedoraproject.org> - 1.3-11
- Autorebuild for GCC 4.3
More information about the fedora-extras-commits
mailing list