[gnome-commander/no_return_value_in_unicode2utf8_function: 2/2] Remove return value of unicode2utf8, change cast to char_type, some cleanup
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/no_return_value_in_unicode2utf8_function: 2/2] Remove return value of unicode2utf8, change cast to char_type, some cleanup
- Date: Sun, 21 Nov 2021 18:14:43 +0000 (UTC)
commit d9410f2a1d3a3ae1c0444969120510704a8ac787
Author: Uwe Scholz <u scholz83 gmx de>
Date: Sun Nov 21 19:13:58 2021 +0100
Remove return value of unicode2utf8, change cast to char_type, some cleanup
src/intviewer/viewer-utils.cc | 37 +++++++++++++++----------------------
src/intviewer/viewer-utils.h | 2 +-
2 files changed, 16 insertions(+), 23 deletions(-)
---
diff --git a/src/intviewer/viewer-utils.cc b/src/intviewer/viewer-utils.cc
index 6d9c6e59..ec135fd7 100644
--- a/src/intviewer/viewer-utils.cc
+++ b/src/intviewer/viewer-utils.cc
@@ -29,39 +29,32 @@
using namespace std;
-int unicode2utf8 (unsigned int unicode, char_type *out)
+void unicode2utf8 (unsigned int unicode, char_type *out)
{
- int bytes_needed = 0;
- if (unicode<0x80)
+ if (unicode < 0x80) // bytes needed = 1
{
- bytes_needed = 1;
- *out = (unsigned char)(unicode&0xFF);
+ *out = (char_type)(unicode & 0xFF);
}
else
- if (unicode<0x0800)
+ if (unicode < 0x0800) // bytes needed = 2
{
- bytes_needed = 2;
- *out = (unsigned char)(unicode>>6 | 0xC0);
- *out |= ((unsigned char)((unicode&0x3F)| 0x80) << 8);
+ *out = (char_type)( unicode >> 6 | 0xC0);
+ *out |= ((char_type)(( unicode & 0x3F) | 0x80) << 8);
}
else
- if (unicode<0x10000)
+ if (unicode < 0x10000) // bytes needed = 3
{
- bytes_needed = 3;
- *out = (unsigned char)((unicode>>12) | 0xE0);
- *out |= ((unsigned char)(((unicode>>6) & 0x3F) | 0x80) << 8);
- *out |= ((unsigned char)((unicode & 0x3F) | 0x80) << 16);
+ *out = (char_type) (( unicode >> 12) | 0xE0);
+ *out |= ((char_type)((( unicode >> 6) & 0x3F) | 0x80) << 8);
+ *out |= ((char_type) (( unicode & 0x3F) | 0x80) << 16);
}
- else
+ else // bytes needed = 4
{
- bytes_needed = 4;
- *out = (unsigned char)((unicode>>18) | 0xE0);
- *out |= ((unsigned char)(((unicode>>12) & 0x3F) | 0x80) << 8);
- *out |= ((unsigned char)(((unicode>>6) & 0x3F) | 0x80) << 16);
- *out |= ((unsigned char)((unicode & 0x3F) | 0x80) << 24);
+ *out = (char_type) (( unicode >> 18) | 0xE0);
+ *out |= ((char_type)((( unicode >> 12) & 0x3F) | 0x80) << 8);
+ *out |= ((char_type)((( unicode >> 6) & 0x3F) | 0x80) << 16);
+ *out |= ((char_type) (( unicode & 0x3F) | 0x80) << 24);
}
-
- return bytes_needed;
}
diff --git a/src/intviewer/viewer-utils.h b/src/intviewer/viewer-utils.h
index c561e698..cb21f359 100644
--- a/src/intviewer/viewer-utils.h
+++ b/src/intviewer/viewer-utils.h
@@ -26,7 +26,7 @@
#define GVIEWER_DEFAULT_PATH_PREFIX "/gnome-commander/internal_viewer/"
-int unicode2utf8(unsigned int unicode, char_type *out);
+void unicode2utf8(unsigned int unicode, char_type *out);
char_type *convert_utf8_to_chartype_array(const gchar *utf8text, /*out*/ int &array_length);
guint8 *mem_reverse(const guint8 *buffer, guint buflen);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]