summaryrefslogtreecommitdiff
path: root/src/core/wee-utf8.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2007-10-31 17:09:43 +0100
committerSebastien Helleu <flashcode@flashtux.org>2007-10-31 17:09:43 +0100
commita3cb19dbea05886dafc65a35e7c959414bad12e5 (patch)
tree671fc4c491f24d18ced3b35aaf9a56f214485974 /src/core/wee-utf8.c
parenteb2835fa24d510a46f8616855624f7ac1ddd19b8 (diff)
downloadweechat-a3cb19dbea05886dafc65a35e7c959414bad12e5.zip
Renamed many functions, removed all IRC specific stuff
Diffstat (limited to 'src/core/wee-utf8.c')
-rw-r--r--src/core/wee-utf8.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/core/wee-utf8.c b/src/core/wee-utf8.c
index 176fee797..c7b8596d3 100644
--- a/src/core/wee-utf8.c
+++ b/src/core/wee-utf8.c
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* utf8.c: UTF-8 string functions for WeeChat */
+/* wee-utf8.c: UTF-8 string functions for WeeChat */
#ifdef HAVE_CONFIG_H
@@ -27,9 +27,9 @@
#include <string.h>
#include "weechat.h"
-#include "utf8.h"
-#include "util.h"
-#include "weeconfig.h"
+#include "wee-utf8.h"
+#include "wee-config.h"
+#include "wee-string.h"
int local_utf8 = 0;
@@ -41,7 +41,7 @@ int local_utf8 = 0;
void
utf8_init ()
{
- local_utf8 = (ascii_strcasecmp (local_charset, "UTF-8") == 0);
+ local_utf8 = (string_strcasecmp (local_charset, "UTF-8") == 0);
}
/*
@@ -260,7 +260,7 @@ utf8_strlen (char *string)
}
/*
- * utf8_strnlen: return length of an UTF-8 string, for N bytes
+ * utf8_strnlen: return length of an UTF-8 string, for N bytes max in string
*/
int
@@ -283,11 +283,12 @@ utf8_strnlen (char *string, int bytes)
}
/*
- * utf8_width_screen: return number of chars needed on screen to display UTF-8 string
+ * utf8_strlen_screen: return number of chars needed on screen to display
+ * UTF-8 string
*/
int
-utf8_width_screen (char *string)
+utf8_strlen_screen (char *string)
{
int length, num_char;
wchar_t *wstring;
@@ -315,6 +316,30 @@ utf8_width_screen (char *string)
}
/*
+ * utf8_char_size_screen: return number of chars needed on screen to display
+ * UTF-8 char
+ */
+
+int
+utf8_char_size_screen (char *string)
+{
+ int char_size;
+ char utf_char[16];
+
+ if (!string)
+ return 0;
+
+ char_size = utf8_char_size (string);
+ if (char_size == 0)
+ return 0;
+
+ memcpy (utf_char, string, char_size);
+ utf_char[char_size] = '\0';
+
+ return utf8_strlen_screen (utf_char);
+}
+
+/*
* utf8_add_offset: moves forward N chars in an UTF-8 string
*/
@@ -386,11 +411,11 @@ utf8_pos (char *string, int real_pos)
}
/*
- * utf8_get_wc: get wide char from string (first char)
+ * utf8_get_wide_char: get wide char from string (first char)
*/
wint_t
-utf8_get_wc (char *string)
+utf8_get_wide_char (char *string)
{
int char_size;
wint_t result;