Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-23 17:52:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-23 17:52:51 +0400
commite89107927bcc8297c74f9a8cb10562e6defc867c (patch)
tree7925d6bba50b803ab1ff5080e9b44b2e98a3059f /source/blender/blenlib
parent66ef02aaa332039c2338bd4680aba34c748fb319 (diff)
- fix for error with utf8 textinput for buttons
- ensure input is valid utf8 from ghost and NULL then complain if its not. - added function to get utf8 size BLI_str_utf8_size()
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_string_utf8.h1
-rw-r--r--source/blender/blenlib/intern/string_utf8.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h
index 765ae93828e..bcb641d79d8 100644
--- a/source/blender/blenlib/BLI_string_utf8.h
+++ b/source/blender/blenlib/BLI_string_utf8.h
@@ -37,6 +37,7 @@ char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy);
int BLI_utf8_invalid_byte(const char *str, int length);
int BLI_utf8_invalid_strip(char *str, int length);
+int BLI_str_utf8_size(const char *p); /* warning, can return -1 on bad chars */
/* copied from glib */
unsigned int BLI_str_utf8_as_unicode(const char *p);
unsigned int BLI_str_utf8_as_unicode_and_size(const char *p, size_t *index);
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index b1ad04eb70d..b4c58d3bab4 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -312,6 +312,18 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size
}
+/* uses glib functions but not from glib */
+/* gets the size of a single utf8 char */
+int BLI_str_utf8_size(const char *p)
+{
+ int mask = 0, len;
+ unsigned char c = (unsigned char) *p;
+
+ UTF8_COMPUTE (c, mask, len);
+
+ return len;
+}
+
/* was g_utf8_get_char */
/**
* BLI_str_utf8_as_unicode: