Blender V2.61 - r43446

BLI_string_utf8.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): none yet.
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00023 #ifndef BLI_STRING_UTF8_H
00024 #define BLI_STRING_UTF8_H
00025 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 char        *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy);
00035 char        *BLI_strncat_utf8(char *dst, const char *src, size_t maxncpy);
00036 int          BLI_utf8_invalid_byte(const char *str, int length);
00037 int          BLI_utf8_invalid_strip(char *str, int length);
00038 
00039 int          BLI_str_utf8_size(const char *p); /* warning, can return -1 on bad chars */
00040     /* copied from glib */
00041 unsigned int BLI_str_utf8_as_unicode(const char *p);
00042 unsigned int BLI_str_utf8_as_unicode_and_size(const char *p, size_t *index);
00043 unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index);
00044 size_t       BLI_str_utf8_from_unicode(unsigned int c, char *outbuf);
00045 
00046 char        *BLI_str_find_prev_char_utf8(const char *str, const char *p);
00047 char        *BLI_str_find_next_char_utf8(const char *p, const char *end);
00048 char        *BLI_str_prev_char_utf8(const char *p);
00049 
00050     /* wchar_t functions, copied from blenders own font.c originally */
00051 size_t       BLI_wstrlen_utf8(const wchar_t *src);
00052 size_t       BLI_strlen_utf8(const char *strc);
00053 size_t       BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t maxcpy);
00054 size_t       BLI_strncpy_wchar_from_utf8(wchar_t *dst, const char *src, const size_t maxcpy);
00055 
00056 #define      BLI_UTF8_MAX 6
00057 #define      BLI_UTF8_ERR ((unsigned int)-1)
00058 
00059 #ifdef __cplusplus
00060 }
00061 #endif
00062 
00063 #endif