2011-10-20 09:47:05 +00:00
|
|
|
/*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BLI_STRING_UTF8_H__
|
|
|
|
#define __BLI_STRING_UTF8_H__
|
2011-10-20 09:47:05 +00:00
|
|
|
|
2011-10-20 10:47:38 +00:00
|
|
|
/** \file BLI_string_utf8.h
|
2011-10-20 09:47:05 +00:00
|
|
|
* \ingroup bli
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-10-10 04:47:53 +00:00
|
|
|
char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy);
|
|
|
|
char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy);
|
2011-10-21 00:01:22 +00:00
|
|
|
int BLI_utf8_invalid_byte(const char *str, int length);
|
|
|
|
int BLI_utf8_invalid_strip(char *str, int length);
|
2011-10-20 09:47:05 +00:00
|
|
|
|
2011-10-23 13:52:51 +00:00
|
|
|
int BLI_str_utf8_size(const char *p); /* warning, can return -1 on bad chars */
|
2012-05-12 20:39:39 +00:00
|
|
|
/* copied from glib */
|
2011-10-21 00:01:22 +00:00
|
|
|
unsigned int BLI_str_utf8_as_unicode(const char *p);
|
2012-10-10 04:47:53 +00:00
|
|
|
unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t *__restrict index);
|
|
|
|
unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index);
|
2012-05-12 20:39:39 +00:00
|
|
|
size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf);
|
2011-10-21 00:01:22 +00:00
|
|
|
|
|
|
|
char *BLI_str_find_prev_char_utf8(const char *str, const char *p);
|
|
|
|
char *BLI_str_find_next_char_utf8(const char *p, const char *end);
|
|
|
|
char *BLI_str_prev_char_utf8(const char *p);
|
2011-10-20 09:47:05 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
/* wchar_t functions, copied from blenders own font.c originally */
|
2011-10-21 00:01:22 +00:00
|
|
|
size_t BLI_wstrlen_utf8(const wchar_t *src);
|
|
|
|
size_t BLI_strlen_utf8(const char *strc);
|
* New string property subtype: PASSWORD
When this new subtypes is used, then string of property is hidden using
asterisks, e.g.: mysecretpassword -> ****************
This code was reviewed and modified by Brecht. Thanks very much:
- https://codereview.appspot.com/6713044/
This new subtype of string property is intended mostly for Add-on developers
writing Add-on which communicates with some server (http, sql, ftp, verse,
etc.). When this server requires user authentication and user has to type
username and password, then current API didn't allow to type 'hidden' password,
e.g. when you want to demonstrate this script, then everybody can see this
security password. Some examples of Add-on which could use this new subtype:
- On-line database of textures
- Integration of render farm
- Integration of Verse
Security Notes:
- You can copy paste hiddent string of property from text input using (Ctrl-C, Ctrl-V),
but you can do this in other GUI toolkits too (this behavior it is widely used).
- Text of string property is stored in plain text, but it is widely used in other
GUI toolkits (Qt, Gtk, etc.).
Simple examples:
- https://dl.dropbox.com/u/369894/draw_op_passwd.py
- https://dl.dropbox.com/u/369894/blender-password.png
2012-10-26 12:58:54 +00:00
|
|
|
size_t BLI_strlen_range_utf8(const char *start, const char *end);
|
2012-10-10 04:47:53 +00:00
|
|
|
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxcpy);
|
|
|
|
size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst, const char *__restrict src, const size_t maxcpy);
|
2011-10-21 00:01:22 +00:00
|
|
|
|
2011-10-21 00:48:02 +00:00
|
|
|
#define BLI_UTF8_MAX 6
|
|
|
|
#define BLI_UTF8_ERR ((unsigned int)-1)
|
2011-10-20 09:47:05 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|