2011-10-15 14:56:47 +04:00
|
|
|
/*
|
|
|
|
Common strings utilities
|
2009-04-09 14:29:00 +04:00
|
|
|
|
2018-01-01 09:54:11 +03:00
|
|
|
Copyright (C) 2007-2018
|
2014-02-12 10:33:10 +04:00
|
|
|
Free Software Foundation, Inc.
|
2011-10-15 14:56:47 +04:00
|
|
|
|
|
|
|
Written by:
|
|
|
|
Rostislav Benes, 2007
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
This file is part of the Midnight Commander.
|
|
|
|
|
|
|
|
The Midnight Commander 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 3 of the License,
|
|
|
|
or (at your option) any later version.
|
2009-04-09 14:29:00 +04:00
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
The Midnight Commander is distributed in the hope that it will be useful,
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
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
|
2011-10-15 14:56:47 +04:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2013-04-09 13:56:43 +04:00
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <langinfo.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2010-01-20 18:11:52 +03:00
|
|
|
#include "lib/global.h"
|
2016-11-12 18:58:05 +03:00
|
|
|
#include "lib/util.h" /* MC_PTR_FREE */
|
2010-01-21 15:17:26 +03:00
|
|
|
#include "lib/strutil.h"
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/*** global variables ****************************************************************************/
|
|
|
|
|
|
|
|
GIConv str_cnv_to_term;
|
|
|
|
GIConv str_cnv_from_term;
|
|
|
|
GIConv str_cnv_not_convert = INVALID_CONV;
|
|
|
|
|
|
|
|
/*** file scope macro definitions ****************************************************************/
|
|
|
|
|
|
|
|
/*** file scope type declarations ****************************************************************/
|
|
|
|
|
|
|
|
/*** file scope variables ************************************************************************/
|
|
|
|
|
|
|
|
/* names, that are used for utf-8 */
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
static const char *str_utf8_encodings[] = {
|
2010-11-08 13:21:45 +03:00
|
|
|
"utf-8",
|
|
|
|
"utf8",
|
|
|
|
NULL
|
2009-04-14 14:29:01 +04:00
|
|
|
};
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/* standard 8bit encodings, no wide or multibytes characters */
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
static const char *str_8bit_encodings[] = {
|
2009-04-14 14:29:01 +04:00
|
|
|
"cp-1251",
|
|
|
|
"cp1251",
|
|
|
|
"cp-1250",
|
|
|
|
"cp1250",
|
|
|
|
"cp-866",
|
|
|
|
"cp866",
|
2009-09-21 16:43:08 +04:00
|
|
|
"ibm-866",
|
|
|
|
"ibm866",
|
2009-04-14 14:29:01 +04:00
|
|
|
"cp-850",
|
|
|
|
"cp850",
|
|
|
|
"cp-852",
|
|
|
|
"cp852",
|
|
|
|
"iso-8859",
|
|
|
|
"iso8859",
|
|
|
|
"koi8",
|
|
|
|
NULL
|
2009-04-09 14:29:00 +04:00
|
|
|
};
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/* terminal encoding */
|
2009-10-29 22:04:44 +03:00
|
|
|
static char *codeset = NULL;
|
2012-03-22 17:37:22 +04:00
|
|
|
static char *term_encoding = NULL;
|
2010-11-08 13:21:45 +03:00
|
|
|
/* function for encoding specific operations */
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
static struct str_class used_class;
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/*** file scope functions ************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/* if enc is same encoding like on terminal */
|
2009-04-14 14:29:01 +04:00
|
|
|
static int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_test_not_convert (const char *enc)
|
|
|
|
{
|
|
|
|
return g_ascii_strcasecmp (enc, codeset) == 0;
|
2009-04-09 14:29:00 +04:00
|
|
|
}
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2009-04-22 20:35:32 +04:00
|
|
|
static estr_t
|
2009-04-22 22:47:45 +04:00
|
|
|
_str_convert (GIConv coder, const char *string, int size, GString * buffer)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
2010-11-08 13:21:45 +03:00
|
|
|
estr_t state = ESTR_SUCCESS;
|
2009-04-14 14:29:01 +04:00
|
|
|
gssize left;
|
2009-04-29 20:05:01 +04:00
|
|
|
gsize bytes_read = 0;
|
|
|
|
gsize bytes_written = 0;
|
2013-07-12 20:43:00 +04:00
|
|
|
|
2013-07-23 14:10:56 +04:00
|
|
|
errno = 0; /* FIXME: is it really needed? */
|
2009-04-20 15:09:32 +04:00
|
|
|
|
2009-04-22 20:35:32 +04:00
|
|
|
if (coder == INVALID_CONV)
|
2010-11-08 13:21:45 +03:00
|
|
|
return ESTR_FAILURE;
|
2009-04-22 20:35:32 +04:00
|
|
|
|
2009-04-20 14:09:59 +04:00
|
|
|
if (string == NULL || buffer == NULL)
|
2010-11-08 13:21:45 +03:00
|
|
|
return ESTR_FAILURE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (! used_class.is_valid_string (string))
|
|
|
|
{
|
|
|
|
return ESTR_FAILURE;
|
|
|
|
}
|
|
|
|
*/
|
2009-04-20 14:09:59 +04:00
|
|
|
if (size < 0)
|
2010-11-08 13:21:45 +03:00
|
|
|
size = strlen (string);
|
2009-04-20 14:09:59 +04:00
|
|
|
else
|
|
|
|
{
|
2010-11-08 13:21:45 +03:00
|
|
|
left = strlen (string);
|
|
|
|
if (left < size)
|
|
|
|
size = left;
|
2009-04-20 14:09:59 +04:00
|
|
|
}
|
2009-04-14 14:29:01 +04:00
|
|
|
|
2009-04-20 14:09:59 +04:00
|
|
|
left = size;
|
|
|
|
g_iconv (coder, NULL, NULL, NULL, NULL);
|
2009-04-14 14:29:01 +04:00
|
|
|
|
2013-07-12 20:43:00 +04:00
|
|
|
while (left != 0)
|
2009-04-20 14:09:59 +04:00
|
|
|
{
|
2013-07-12 20:43:00 +04:00
|
|
|
gchar *tmp_buff;
|
2014-07-15 16:53:06 +04:00
|
|
|
GError *mcerror = NULL;
|
2013-07-12 20:43:00 +04:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
tmp_buff = g_convert_with_iconv ((const gchar *) string,
|
2014-07-15 16:53:06 +04:00
|
|
|
left, coder, &bytes_read, &bytes_written, &mcerror);
|
|
|
|
if (mcerror != NULL)
|
2010-11-08 13:21:45 +03:00
|
|
|
{
|
2014-07-15 16:53:06 +04:00
|
|
|
int code = mcerror->code;
|
2010-11-08 13:21:45 +03:00
|
|
|
|
2014-07-15 16:53:06 +04:00
|
|
|
g_error_free (mcerror);
|
|
|
|
mcerror = NULL;
|
2010-11-08 13:21:45 +03:00
|
|
|
|
|
|
|
switch (code)
|
|
|
|
{
|
|
|
|
case G_CONVERT_ERROR_NO_CONVERSION:
|
|
|
|
/* Conversion between the requested character sets is not supported. */
|
|
|
|
tmp_buff = g_strnfill (strlen (string), '?');
|
|
|
|
g_string_append (buffer, tmp_buff);
|
|
|
|
g_free (tmp_buff);
|
|
|
|
return ESTR_FAILURE;
|
|
|
|
|
|
|
|
case G_CONVERT_ERROR_ILLEGAL_SEQUENCE:
|
|
|
|
/* Invalid byte sequence in conversion input. */
|
|
|
|
if ((tmp_buff == NULL) && (bytes_read != 0))
|
|
|
|
/* recode valid byte sequence */
|
|
|
|
tmp_buff = g_convert_with_iconv ((const gchar *) string,
|
|
|
|
bytes_read, coder, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (tmp_buff != NULL)
|
|
|
|
{
|
|
|
|
g_string_append (buffer, tmp_buff);
|
|
|
|
g_free (tmp_buff);
|
|
|
|
}
|
|
|
|
|
2013-07-12 20:43:00 +04:00
|
|
|
if ((int) bytes_read >= left)
|
2010-11-08 13:21:45 +03:00
|
|
|
return ESTR_PROBLEM;
|
2013-07-12 20:43:00 +04:00
|
|
|
|
|
|
|
string += bytes_read + 1;
|
|
|
|
size -= (bytes_read + 1);
|
|
|
|
left -= (bytes_read + 1);
|
|
|
|
g_string_append_c (buffer, *(string - 1));
|
2010-11-08 13:21:45 +03:00
|
|
|
state = ESTR_PROBLEM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case G_CONVERT_ERROR_PARTIAL_INPUT:
|
|
|
|
/* Partial character sequence at end of input. */
|
|
|
|
g_string_append (buffer, tmp_buff);
|
|
|
|
g_free (tmp_buff);
|
|
|
|
if ((int) bytes_read < left)
|
|
|
|
{
|
|
|
|
left = left - bytes_read;
|
|
|
|
tmp_buff = g_strnfill (left, '?');
|
|
|
|
g_string_append (buffer, tmp_buff);
|
|
|
|
g_free (tmp_buff);
|
|
|
|
}
|
|
|
|
return ESTR_PROBLEM;
|
|
|
|
|
|
|
|
case G_CONVERT_ERROR_BAD_URI: /* Don't know how handle this error :( */
|
|
|
|
case G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: /* Don't know how handle this error :( */
|
|
|
|
case G_CONVERT_ERROR_FAILED: /* Conversion failed for some reason. */
|
|
|
|
default:
|
|
|
|
g_free (tmp_buff);
|
|
|
|
return ESTR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2013-07-12 20:43:00 +04:00
|
|
|
else if (tmp_buff == NULL)
|
|
|
|
{
|
|
|
|
g_string_append (buffer, string);
|
|
|
|
return ESTR_PROBLEM;
|
|
|
|
}
|
|
|
|
else if (*tmp_buff == '\0')
|
|
|
|
{
|
|
|
|
g_free (tmp_buff);
|
|
|
|
g_string_append (buffer, string);
|
|
|
|
return state;
|
|
|
|
}
|
2010-11-08 13:21:45 +03:00
|
|
|
else
|
|
|
|
{
|
2013-07-12 20:43:00 +04:00
|
|
|
g_string_append (buffer, tmp_buff);
|
|
|
|
g_free (tmp_buff);
|
|
|
|
string += bytes_read;
|
|
|
|
left -= bytes_read;
|
2010-11-08 13:21:45 +03:00
|
|
|
}
|
2009-04-14 14:29:01 +04:00
|
|
|
}
|
2013-07-12 20:43:00 +04:00
|
|
|
|
2009-04-20 14:09:59 +04:00
|
|
|
return state;
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
|
|
|
str_test_encoding_class (const char *encoding, const char **table)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
if (encoding != NULL)
|
|
|
|
{
|
|
|
|
int t;
|
|
|
|
|
|
|
|
for (t = 0; table[t] != NULL; t++)
|
|
|
|
if (g_ascii_strncasecmp (encoding, table[t], strlen (table[t])) == 0)
|
|
|
|
result++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
|
|
|
str_choose_str_functions (void)
|
|
|
|
{
|
|
|
|
if (str_test_encoding_class (codeset, str_utf8_encodings))
|
|
|
|
used_class = str_utf8_init ();
|
|
|
|
else if (str_test_encoding_class (codeset, str_8bit_encodings))
|
|
|
|
used_class = str_8bit_init ();
|
|
|
|
else
|
|
|
|
used_class = str_ascii_init ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/*** public functions ****************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
GIConv
|
|
|
|
str_crt_conv_to (const char *to_enc)
|
|
|
|
{
|
|
|
|
return (!str_test_not_convert (to_enc)) ? g_iconv_open (to_enc, codeset) : str_cnv_not_convert;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
GIConv
|
|
|
|
str_crt_conv_from (const char *from_enc)
|
|
|
|
{
|
|
|
|
return (!str_test_not_convert (from_enc))
|
|
|
|
? g_iconv_open (codeset, from_enc) : str_cnv_not_convert;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void
|
|
|
|
str_close_conv (GIConv conv)
|
|
|
|
{
|
|
|
|
if (conv != str_cnv_not_convert)
|
|
|
|
g_iconv_close (conv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-22 20:35:32 +04:00
|
|
|
estr_t
|
2009-04-22 22:47:45 +04:00
|
|
|
str_convert (GIConv coder, const char *string, GString * buffer)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
2009-04-22 20:35:32 +04:00
|
|
|
return _str_convert (coder, string, -1, buffer);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-22 20:35:32 +04:00
|
|
|
estr_t
|
2009-04-22 22:47:45 +04:00
|
|
|
str_nconvert (GIConv coder, const char *string, int size, GString * buffer)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
2009-04-22 20:35:32 +04:00
|
|
|
return _str_convert (coder, string, size, buffer);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-29 20:08:33 +04:00
|
|
|
gchar *
|
2014-07-15 16:53:06 +04:00
|
|
|
str_conv_gerror_message (GError * mcerror, const char *def_msg)
|
2009-04-29 20:08:33 +04:00
|
|
|
{
|
2014-07-15 16:53:06 +04:00
|
|
|
return used_class.conv_gerror_message (mcerror, def_msg);
|
2009-04-29 20:08:33 +04:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-22 20:35:32 +04:00
|
|
|
estr_t
|
2009-04-22 22:47:45 +04:00
|
|
|
str_vfs_convert_from (GIConv coder, const char *string, GString * buffer)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
2013-07-12 20:43:00 +04:00
|
|
|
estr_t result = ESTR_SUCCESS;
|
2009-04-09 14:29:00 +04:00
|
|
|
|
2009-04-14 14:29:01 +04:00
|
|
|
if (coder == str_cnv_not_convert)
|
2010-11-08 13:21:45 +03:00
|
|
|
g_string_append (buffer, string != NULL ? string : "");
|
2009-04-14 14:29:01 +04:00
|
|
|
else
|
2010-11-08 13:21:45 +03:00
|
|
|
result = _str_convert (coder, string, -1, buffer);
|
2009-04-09 14:29:00 +04:00
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
return result;
|
|
|
|
}
|
2009-04-09 14:29:00 +04:00
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-22 20:35:32 +04:00
|
|
|
estr_t
|
2010-11-08 13:21:45 +03:00
|
|
|
str_vfs_convert_to (GIConv coder, const char *string, int size, GString * buffer)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
return used_class.vfs_convert_to (coder, string, size, buffer);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
2009-04-14 14:29:01 +04:00
|
|
|
str_printf (GString * buffer, const char *format, ...)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start (ap, format);
|
2013-07-12 20:43:00 +04:00
|
|
|
|
2009-04-18 12:50:32 +04:00
|
|
|
g_string_append_vprintf (buffer, format, ap);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
va_end (ap);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
2009-04-14 14:29:01 +04:00
|
|
|
str_insert_replace_char (GString * buffer)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
used_class.insert_replace_char (buffer);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-22 20:35:32 +04:00
|
|
|
estr_t
|
2010-11-08 13:21:45 +03:00
|
|
|
str_translate_char (GIConv conv, const char *keys, size_t ch_size, char *output, size_t out_size)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
size_t left;
|
|
|
|
size_t cnv;
|
2009-04-09 14:29:00 +04:00
|
|
|
|
2009-04-15 13:22:34 +04:00
|
|
|
g_iconv (conv, NULL, NULL, NULL, NULL);
|
2009-04-09 14:29:00 +04:00
|
|
|
|
2009-04-14 14:29:01 +04:00
|
|
|
left = (ch_size == (size_t) (-1)) ? strlen (keys) : ch_size;
|
2009-04-09 14:29:00 +04:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
cnv = g_iconv (conv, (gchar **) & keys, &left, &output, &out_size);
|
|
|
|
if (cnv == (size_t) (-1))
|
2009-04-22 20:35:32 +04:00
|
|
|
return (errno == EINVAL) ? ESTR_PROBLEM : ESTR_FAILURE;
|
2013-07-12 20:43:00 +04:00
|
|
|
|
|
|
|
output[0] = '\0';
|
|
|
|
return ESTR_SUCCESS;
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2009-05-07 13:20:34 +04:00
|
|
|
const char *
|
|
|
|
str_detect_termencoding (void)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
2012-03-22 17:37:22 +04:00
|
|
|
if (term_encoding == NULL)
|
|
|
|
{
|
|
|
|
/* On Linux, nl_langinfo (CODESET) returns upper case UTF-8 whether the LANG is set
|
|
|
|
to utf-8 or UTF-8.
|
|
|
|
On Mac OS X, it returns the same case as the LANG input.
|
|
|
|
So let tranform result of nl_langinfo (CODESET) to upper case unconditionally. */
|
|
|
|
term_encoding = g_ascii_strup (nl_langinfo (CODESET), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return term_encoding;
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2011-04-06 13:01:27 +04:00
|
|
|
gboolean
|
2009-04-17 01:28:02 +04:00
|
|
|
str_isutf8 (const char *codeset_name)
|
2009-04-09 18:23:08 +04:00
|
|
|
{
|
2011-04-06 13:01:27 +04:00
|
|
|
return (str_test_encoding_class (codeset_name, str_utf8_encodings) != 0);
|
2009-04-09 18:23:08 +04:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
void
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_init_strings (const char *termenc)
|
|
|
|
{
|
2012-03-22 17:37:22 +04:00
|
|
|
codeset = termenc != NULL ? g_ascii_strup (termenc, -1) : g_strdup (str_detect_termencoding ());
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2009-04-15 13:22:34 +04:00
|
|
|
str_cnv_not_convert = g_iconv_open (codeset, codeset);
|
2009-04-14 14:29:01 +04:00
|
|
|
if (str_cnv_not_convert == INVALID_CONV)
|
|
|
|
{
|
2010-11-08 13:21:45 +03:00
|
|
|
if (termenc != NULL)
|
|
|
|
{
|
|
|
|
g_free (codeset);
|
|
|
|
codeset = g_strdup (str_detect_termencoding ());
|
|
|
|
str_cnv_not_convert = g_iconv_open (codeset, codeset);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (str_cnv_not_convert == INVALID_CONV)
|
|
|
|
{
|
|
|
|
g_free (codeset);
|
2013-09-09 16:55:01 +04:00
|
|
|
codeset = g_strdup (DEFAULT_CHARSET);
|
2010-11-08 13:21:45 +03:00
|
|
|
str_cnv_not_convert = g_iconv_open (codeset, codeset);
|
|
|
|
}
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
2009-04-09 14:29:00 +04:00
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_cnv_to_term = str_cnv_not_convert;
|
|
|
|
str_cnv_from_term = str_cnv_not_convert;
|
2009-04-09 14:29:00 +04:00
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_choose_str_functions ();
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
void
|
2009-10-30 04:12:04 +03:00
|
|
|
str_uninit_strings (void)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
2010-01-06 18:33:42 +03:00
|
|
|
if (str_cnv_not_convert != INVALID_CONV)
|
2010-11-08 13:21:45 +03:00
|
|
|
g_iconv_close (str_cnv_not_convert);
|
2016-11-12 18:58:05 +03:00
|
|
|
/* NULL-ize pointers to avoid double free in unit tests */
|
|
|
|
MC_PTR_FREE (term_encoding);
|
|
|
|
MC_PTR_FREE (codeset);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
2009-04-09 14:29:00 +04:00
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_term_form (const char *text)
|
|
|
|
{
|
|
|
|
return used_class.term_form (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
2009-04-24 20:01:06 +04:00
|
|
|
str_fit_to_term (const char *text, int width, align_crt_t just_mode)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
return used_class.fit_to_term (text, width, just_mode);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_term_trim (const char *text, int width)
|
|
|
|
{
|
|
|
|
return used_class.term_trim (text, width);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_term_substring (const char *text, int start, int width)
|
|
|
|
{
|
|
|
|
return used_class.term_substring (text, start, width);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
char *
|
|
|
|
str_get_next_char (char *text)
|
|
|
|
{
|
2009-04-09 14:29:00 +04:00
|
|
|
|
2009-04-14 14:29:01 +04:00
|
|
|
used_class.cnext_char ((const char **) &text);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_cget_next_char (const char *text)
|
|
|
|
{
|
2010-11-08 13:21:45 +03:00
|
|
|
used_class.cnext_char (&text);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
|
|
|
str_next_char (char **text)
|
|
|
|
{
|
|
|
|
used_class.cnext_char ((const char **) text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
|
|
|
str_cnext_char (const char **text)
|
|
|
|
{
|
|
|
|
used_class.cnext_char (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
char *
|
|
|
|
str_get_prev_char (char *text)
|
|
|
|
{
|
|
|
|
used_class.cprev_char ((const char **) &text);
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_cget_prev_char (const char *text)
|
|
|
|
{
|
|
|
|
used_class.cprev_char (&text);
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
|
|
|
str_prev_char (char **text)
|
|
|
|
{
|
|
|
|
used_class.cprev_char ((const char **) text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
|
|
|
str_cprev_char (const char **text)
|
|
|
|
{
|
|
|
|
used_class.cprev_char (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
char *
|
|
|
|
str_get_next_char_safe (char *text)
|
|
|
|
{
|
|
|
|
used_class.cnext_char_safe ((const char **) &text);
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_cget_next_char_safe (const char *text)
|
|
|
|
{
|
|
|
|
used_class.cnext_char_safe (&text);
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
|
|
|
str_next_char_safe (char **text)
|
|
|
|
{
|
|
|
|
used_class.cnext_char_safe ((const char **) text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
|
|
|
str_cnext_char_safe (const char **text)
|
|
|
|
{
|
|
|
|
used_class.cnext_char_safe (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
char *
|
|
|
|
str_get_prev_char_safe (char *text)
|
|
|
|
{
|
|
|
|
used_class.cprev_char_safe ((const char **) &text);
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_cget_prev_char_safe (const char *text)
|
|
|
|
{
|
|
|
|
used_class.cprev_char_safe (&text);
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
|
|
|
str_prev_char_safe (char **text)
|
|
|
|
{
|
|
|
|
used_class.cprev_char_safe ((const char **) text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
|
|
|
str_cprev_char_safe (const char **text)
|
|
|
|
{
|
|
|
|
used_class.cprev_char_safe (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_next_noncomb_char (char **text)
|
|
|
|
{
|
|
|
|
return used_class.cnext_noncomb_char ((const char **) text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_cnext_noncomb_char (const char **text)
|
|
|
|
{
|
|
|
|
return used_class.cnext_noncomb_char (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_prev_noncomb_char (char **text, const char *begin)
|
|
|
|
{
|
|
|
|
return used_class.cprev_noncomb_char ((const char **) text, begin);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_cprev_noncomb_char (const char **text, const char *begin)
|
|
|
|
{
|
|
|
|
return used_class.cprev_noncomb_char (text, begin);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_is_valid_char (const char *ch, size_t size)
|
|
|
|
{
|
|
|
|
return used_class.is_valid_char (ch, size);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_term_width1 (const char *text)
|
|
|
|
{
|
|
|
|
return used_class.term_width1 (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_term_width2 (const char *text, size_t length)
|
|
|
|
{
|
|
|
|
return used_class.term_width2 (text, length);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_term_char_width (const char *text)
|
|
|
|
{
|
|
|
|
return used_class.term_char_width (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
2009-04-14 14:29:01 +04:00
|
|
|
str_offset_to_pos (const char *text, size_t length)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
return used_class.offset_to_pos (text, length);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
2009-04-14 14:29:01 +04:00
|
|
|
str_length (const char *text)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
return used_class.length (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-17 12:46:06 +04:00
|
|
|
int
|
|
|
|
str_length_char (const char *text)
|
|
|
|
{
|
2010-11-08 13:21:45 +03:00
|
|
|
return str_cget_next_char_safe (text) - text;
|
2009-04-17 12:46:06 +04:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
2009-04-14 14:29:01 +04:00
|
|
|
str_length2 (const char *text, int size)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
return used_class.length2 (text, size);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
2009-04-14 14:29:01 +04:00
|
|
|
str_length_noncomb (const char *text)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
return used_class.length_noncomb (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_column_to_pos (const char *text, size_t pos)
|
|
|
|
{
|
|
|
|
return used_class.column_to_pos (text, pos);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_isspace (const char *ch)
|
|
|
|
{
|
2012-12-12 10:47:47 +04:00
|
|
|
return used_class.char_isspace (ch);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
2009-04-14 14:29:01 +04:00
|
|
|
str_ispunct (const char *ch)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
2012-12-12 10:47:47 +04:00
|
|
|
return used_class.char_ispunct (ch);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_isalnum (const char *ch)
|
|
|
|
{
|
2012-12-12 10:47:47 +04:00
|
|
|
return used_class.char_isalnum (ch);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_isdigit (const char *ch)
|
|
|
|
{
|
2012-12-12 10:47:47 +04:00
|
|
|
return used_class.char_isdigit (ch);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
int
|
2009-04-14 14:29:01 +04:00
|
|
|
str_toupper (const char *ch, char **out, size_t * remain)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
2012-12-12 10:47:47 +04:00
|
|
|
return used_class.char_toupper (ch, out, remain);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
int
|
2009-04-14 14:29:01 +04:00
|
|
|
str_tolower (const char *ch, char **out, size_t * remain)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
2012-12-12 10:47:47 +04:00
|
|
|
return used_class.char_tolower (ch, out, remain);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_isprint (const char *ch)
|
|
|
|
{
|
2012-12-12 10:47:47 +04:00
|
|
|
return used_class.char_isprint (ch);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2012-11-18 13:28:57 +04:00
|
|
|
gboolean
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_iscombiningmark (const char *ch)
|
|
|
|
{
|
2012-12-12 10:47:47 +04:00
|
|
|
return used_class.char_iscombiningmark (ch);
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_trunc (const char *text, int width)
|
|
|
|
{
|
|
|
|
return used_class.trunc (text, width);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
char *
|
|
|
|
str_create_search_needle (const char *needle, int case_sen)
|
|
|
|
{
|
|
|
|
return used_class.create_search_needle (needle, case_sen);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
str_release_search_needle (char *needle, int case_sen)
|
|
|
|
{
|
|
|
|
used_class.release_search_needle (needle, case_sen);
|
2009-04-09 14:29:00 +04:00
|
|
|
}
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_search_first (const char *text, const char *search, int case_sen)
|
|
|
|
{
|
|
|
|
return used_class.search_first (text, search, case_sen);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
const char *
|
|
|
|
str_search_last (const char *text, const char *search, int case_sen)
|
|
|
|
{
|
|
|
|
return used_class.search_last (text, search, case_sen);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_is_valid_string (const char *text)
|
|
|
|
{
|
|
|
|
return used_class.is_valid_string (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
int
|
|
|
|
str_compare (const char *t1, const char *t2)
|
|
|
|
{
|
|
|
|
return used_class.compare (t1, t2);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
int
|
|
|
|
str_ncompare (const char *t1, const char *t2)
|
|
|
|
{
|
|
|
|
return used_class.ncompare (t1, t2);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
int
|
|
|
|
str_casecmp (const char *t1, const char *t2)
|
|
|
|
{
|
|
|
|
return used_class.casecmp (t1, t2);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
int
|
|
|
|
str_ncasecmp (const char *t1, const char *t2)
|
|
|
|
{
|
|
|
|
return used_class.ncasecmp (t1, t2);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
int
|
|
|
|
str_prefix (const char *text, const char *prefix)
|
|
|
|
{
|
|
|
|
return used_class.prefix (text, prefix);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
int
|
|
|
|
str_caseprefix (const char *text, const char *prefix)
|
|
|
|
{
|
|
|
|
return used_class.caseprefix (text, prefix);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
void
|
|
|
|
str_fix_string (char *text)
|
|
|
|
{
|
|
|
|
used_class.fix_string (text);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
char *
|
2009-04-14 14:29:01 +04:00
|
|
|
str_create_key (const char *text, int case_sen)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
return used_class.create_key (text, case_sen);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
char *
|
2009-04-14 14:29:01 +04:00
|
|
|
str_create_key_for_filename (const char *text, int case_sen)
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
{
|
|
|
|
return used_class.create_key_for_filename (text, case_sen);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
int
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_key_collate (const char *t1, const char *t2, int case_sen)
|
|
|
|
{
|
|
|
|
return used_class.key_collate (t1, t2, case_sen);
|
|
|
|
}
|
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-04-09 14:29:00 +04:00
|
|
|
void
|
patches by Rostislav Beneš: mc-01-api
add functions for working with strings
some functions are implemented directlu in strutil.c, others have ascii, 8bit
or utf-8 variant. (8bit means singlebyte encodings, where all characters have
width one). Mc autodetects terminal encoding at start and chooses right
variant. If does not know terminal encoding, chooses ascii variant.
contains functions:
1. for translation strings and growing strings
2. for working with characters (next char, prev char, length in
characters, isspace, isalnum, ...)
3. prepeare for display, replace invalid characters with questionmark,
unprintable with dot, left / right / center align
4. comparing strings
in future all string function from util should be moved into strutil, some
function from util have new variant in strutil.
2008-12-29 01:46:37 +03:00
|
|
|
str_release_key (char *key, int case_sen)
|
|
|
|
{
|
|
|
|
used_class.release_key (key, case_sen);
|
|
|
|
}
|
2010-11-13 21:55:13 +03:00
|
|
|
|
2015-06-20 21:40:26 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2010-11-13 21:55:13 +03:00
|
|
|
void
|
|
|
|
str_msg_term_size (const char *text, int *lines, int *columns)
|
|
|
|
{
|
|
|
|
char *p, *tmp;
|
|
|
|
char *q;
|
|
|
|
char c = '\0';
|
|
|
|
|
|
|
|
*lines = 1;
|
|
|
|
*columns = 0;
|
|
|
|
|
|
|
|
tmp = g_strdup (text);
|
|
|
|
p = tmp;
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
2013-10-15 10:34:04 +04:00
|
|
|
int width;
|
|
|
|
|
2010-11-13 21:55:13 +03:00
|
|
|
q = strchr (p, '\n');
|
|
|
|
if (q != NULL)
|
|
|
|
{
|
|
|
|
c = q[0];
|
|
|
|
q[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
width = str_term_width1 (p);
|
|
|
|
if (width > *columns)
|
|
|
|
*columns = width;
|
|
|
|
|
|
|
|
if (q == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
q[0] = c;
|
|
|
|
p = q + 1;
|
|
|
|
(*lines)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
2011-04-26 11:25:10 +04:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
char *
|
|
|
|
strrstr_skip_count (const char *haystack, const char *needle, size_t skip_count)
|
|
|
|
{
|
|
|
|
char *semi;
|
|
|
|
ssize_t len;
|
|
|
|
|
|
|
|
len = strlen (haystack);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
semi = g_strrstr_len (haystack, len, needle);
|
|
|
|
if (semi == NULL)
|
|
|
|
return NULL;
|
|
|
|
len = semi - haystack - 1;
|
|
|
|
}
|
|
|
|
while (skip_count-- != 0);
|
2013-07-12 20:43:00 +04:00
|
|
|
|
2011-04-26 11:25:10 +04:00
|
|
|
return semi;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2013-02-28 16:55:51 +04:00
|
|
|
/* Interprete string as a non-negative decimal integer, optionally multiplied by various values.
|
|
|
|
*
|
|
|
|
* @param str input value
|
|
|
|
* @param invalid set to TRUE if "str" does not represent a number in this format
|
|
|
|
*
|
|
|
|
* @return non-integer representation of "str", 0 in case of error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
uintmax_t
|
|
|
|
parse_integer (const char *str, gboolean * invalid)
|
|
|
|
{
|
|
|
|
uintmax_t n;
|
|
|
|
char *suffix;
|
|
|
|
strtol_error_t e;
|
|
|
|
|
|
|
|
e = xstrtoumax (str, &suffix, 10, &n, "bcEGkKMPTwYZ0");
|
|
|
|
if (e == LONGINT_INVALID_SUFFIX_CHAR && *suffix == 'x')
|
|
|
|
{
|
|
|
|
uintmax_t multiplier;
|
|
|
|
|
|
|
|
multiplier = parse_integer (suffix + 1, invalid);
|
|
|
|
if (multiplier != 0 && n * multiplier / multiplier != n)
|
|
|
|
{
|
|
|
|
*invalid = TRUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
n *= multiplier;
|
|
|
|
}
|
|
|
|
else if (e != LONGINT_OK)
|
|
|
|
{
|
|
|
|
*invalid = TRUE;
|
|
|
|
n = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|